用到UdpClient的一点经验
Thread.Abort对UdpClient.Receive阻塞的线程无效
http://computer-programming-forum.com/4-csharp/184f9d4ee63704fc.htm
This is not a bug (just very poorly documented :)
Thread.Abort throws an exception only when the thread is in managed code.
Since calling UdpClient.Receive call a blocking function of the WinSock API
it will not receive the abort exception. Only after UdpClient.Receive
finishes (hence you are back in managed code) the Thread.Abort method
re-throws the exception. Lookup in the help files at Thread.Abort().
How to solve this problem?
Use a Socket class (instead of UdpClient) and use the asynchronously methods
BeginReceiveFrom and EndReceiveFrom (of course also for XXXSendTo). These
methods are a litter harder to use but your thread now remains in managed
code while waiting for the receive operation (still unmanaged code) to
complete.
--
Sander Leer
> return from this call unless the UdpClient is closed or data is received.
> Calling Thread.Abort on the blocked thread has no effect.
> The attached code illustrates the problem.
> Is this a bug?
> DAve
封装Socket.BeginReceive/EndReceive以支持Timeout
http://www.cnblogs.com/dytes/archive/2012/08/13/SocketAsyncOpWithTimeout.html
用到UdpClient的一点经验的更多相关文章
- 使用VS2010开发Qt程序的一点经验
导读 相比于Qt Creator,我更喜欢用VS2010来进行开发.虽然启动时间相对较慢,但是VS下强大的快捷键和丰富的插件,以及使用多年的经验,都让我觉得在开发过程中得心应手.其中最重要的一点是,有 ...
- 使用VS2010开发Qt程序的一点经验(转载)
转载:http://www.cnblogs.com/csuftzzk/p/VS_Qt_Experience.html 导读 相比于Qt Creator,我更喜欢用VS2010来进行开发.虽然启动时间相 ...
- 关于删除 hao123 主页设置的一点经验
:first-child { margin-top: 0px; } blockquote>:last-child { margin-bottom: 0px; } --> 说一说关于删除 h ...
- 计算机顶级会议Rankings && 英文投稿的一点经验
英文投稿的一点经验[转载] From: http://chl033.woku.com/article/2893317.html 1. 首先一定要注意杂志的发表范围, 超出范围的千万别投,要不就是浪费时 ...
- Python爬虫脚本 ,Uni-APP复选框做出双向绑定 ,Net5工作流建模 。的一点经验
从业C#开发多年,现在也经常用到Python 做网络爬虫 ,用Uni-app做手机前端.攒了一点经验.供其他多语言开发程序员借鉴吧. Python做爬虫和其他的方式做爬虫最大的区别应该在于. Pyth ...
- 封装RabbitMQ.NET Library 的一点经验总结
这篇文章内容会很短,主要是想给大家分享下我最近在做一个简单的rabbitmq客户端类库的封装的经验总结,说是简单其实一点都不简单.为了节省时间我主要按照Library的执行顺序来介绍,在你看来这里仅仅 ...
- 关于访问MSMQ远端私有队列的一点经验
这里应该将私有队列称做"专用队列"好像更贴切一些了,O(∩_∩)O 可以访问远程主机的MSMQ的私有队列的,这个是毋庸置疑的,但需要说明的是不能通过代码创建私有队列,关于这一点,我 ...
- 封装RabbitMQ.NET Library 的一点经验总结 转载
这篇文章内容会很短,主要是想给大家分享下我最近在做一个简单的rabbitmq客户端类库的封装的经验总结,说是简单其实一点都不简单.为了节省时间我主要按照Library的执行顺序来介绍,在你看来这里仅仅 ...
- 关于Listview布局的一点经验
1.尽量是给item一个固定高度,最外层不要设高度,里面套一层设置一个固定高度:如果用wrap_content的话,之后用alignTop等会出奇怪的问题. 2.如果要使用alignTop align ...
随机推荐
- js apply和call
apply()和call()这两个方法的作用是一样的,都是在特定作用域中调用函数,等于设置函数体内this对象的只,以扩充函数赖以运行的作用域 apply:方法能劫持另外一个对象的方法,继承另外一个对 ...
- python连接mysql数据库遇到的问题
1.源代码: from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy ...
- ECharts基本设置
theme = { // 全图默认背景 // backgroundColor: ‘rgba(0,0,0,0)’, // 默认色板 color: ['#ff7f50','#87cefa','#da70d ...
- CSS3 中 图标编码 icon——Font-Awesome
在做网页开发中经常会用到图标,原来经常会到一些icon网站上找导入到项目中,现在Font-Awesome中的有很多的图标,并且还在不断更新 现在Font-Awesome最新版本是4.7,下载出来的Fo ...
- Mybatis学习笔记4 - 获取自增主键的值
获取自增主键的值:mysql支持自增主键,自增主键值的获取,mybatis也是利用statement.getGenreatedKeys():useGeneratedKeys="true&qu ...
- python 读取文件使用chunksize后逐块迭代操作
chunkers=pd.read_csv('dd.csv',chunksize=10000) tot=pd.Series([]) for piece in chunkers: tot=tot.add( ...
- How to Fold a Julia Fractal
How to Fold a Julia FractalA tale of numbers that like to turn http://acko.net/blog/how-to-fold-a-ju ...
- Barty's Computer 字典树
https://nanti.jisuanke.com/t/17122 Barty have a computer, it can do these two things. Add a new stri ...
- 转:POST 400 Bad Request The request sent by the client was syntactically incorrect
最近在做Web开发的时候,使用$.post提交数据,但是回调函数却没有被触发,按F12看控制台输出是:POST *** 400 Bad Request 后台是SpringMVC的,设置了断点也不会被触 ...
- 转:自定义控件三部曲之动画篇——alpha、scale、translate、rotate、set的xml属性及用法
第一篇: 一.概述 Android的animation由四种类型组成:alpha.scale.translate.rotate,对应android官方文档地址:<Animation Resour ...