任务中的异步套接字操作(Asynchronous socket operations in a Task)
我有一个Threading.Tasks.Task,它处理许多客户端套接字操作(连接,接收和发送)。
我明白,在可能的情况下,最好使用使用Await的非阻塞方法,否则最终会导致“停放线程等待响应”。 但是,虽然Socket类具有异步方法(SendAsync等),但它们与通常的任务并行库异步方法不同,它们不返回任务并且不能等待。
我意识到我可以用TaskCompletionSource包装这些套接字异步方法,但是这样做有什么好处,还是最终仍然会停止线程?
I have a Threading.Tasks.Task that handles a number of client socket operations (connecting, receiving and sending).
I understand that where possible it's best to use non blocking methods using Await because otherwise I'll end up with "parked threads waiting for their response". However, while the Socket class has async methods (SendAsync and so on) they aren't the same as the usual Task Parallel Library async methods, they don't return a Task and cannot be awaited.
I realise that I can wrap these socket async methods with a TaskCompletionSource but is there any benefit to doing so or will it ultimately still be parking the thread?
原文:https://stackoverflow.com/questions/25814575
最满意答案
启动后,您不会在任务容器上调用
resize
。 因为它被放置在另一个BorderContainer
,所以需要明确调整大小以适合自己。 您还可以在BorderContainer
以及html
和body
元素上设置显式大小,但这并不总是理想的。 放入另一个BorderContainer
后显式调整大小仍然是一个好主意。 请参阅有关调整LayoutContainer
大小的文档的本节中间的注释 。You're not calling
resize
on your task container after you start it up. Because it's being placed into anotherBorderContainer
, it needs to explicitly be resized in order to properly fit itself. You can also set explicit sizes on theBorderContainer
and thehtml
andbody
elements, but this isn't always ideal. It's still a good idea to explicitly resize after placing inside anotherBorderContainer
. See the note in the middle of this section of the documentation on sizingLayoutContainer
.
相关问答
更多-
对Dojo中的所有容器尝试“display:inline”而不是“display:block”。 否则,您需要再次进行所有重新调整大小和格式化。 try "display:inline" rather than "display:block" for all containers in Dojo. Else, you need to do all the re-sizing and formatting again.
-
我在我的自定义小部件中混入以下内容: dijit.layout._LayoutWidget, dijit._Templated, dijit._Container 容器允许您包含其他类似BorderContainer的dijits。 模板化可以让你把你的小部件标记放在一个html模板中。 LayoutWidget允许你获得所有的dijit布局并调整好东西。 如果您使用的是dojo 1.4,templatePath现在可以/现在应该是: templateString : dojo.cache("test", ...
-
看看这个例子 http://jsfiddle.net/icsteveoh/ADPZS/ FloatingPane有一个属性'内容'来设置你需要的任何内容。 在这个例子中,内容被设置为声明的一部分,即在创建FloatingPane时。 如果你想动态设置内容,你可以使用 dijit.byId('yourfloatingpaneid').set('content',"Hello again"); 希望这可以帮助 take a look at this example http://jsfiddle.net/i ...
-
使用AS - Flex 4更改BorderContainer背景颜色(Change BorderContainer background color with AS - Flex 4)[2022-07-13]
您可以在ActionScript中设置样式(与属性不同),如下所示: idname.setStyle("backgroundColor", 0xff0000); You can set styles (which are different from properties) in ActionScript like so: idname.setStyle("backgroundColor", 0xff0000); -
在borderContainer中更改contentPane的拆分器位置?(Change splitter position for contentPane in borderContainer?)[2021-12-19]
我在这里找到了一些有用的代码来回答我的问题: http://telliott.net/dojoExamples/dojo-bcExample.html 一个片段: require(["dijit/registry"], function(registry) { var myBC = registry.byId("studiesBorderContainer"); // actual JS object var topPane = registry.byId("studiesTabl ... -
启动后,您不会在任务容器上调用resize 。 因为它被放置在另一个BorderContainer ,所以需要明确调整大小以适合自己。 您还可以在BorderContainer以及html和body元素上设置显式大小,但这并不总是理想的。 放入另一个BorderContainer后显式调整大小仍然是一个好主意。 请参阅有关调整LayoutContainer大小的文档的本节中间的注释 。 You're not calling resize on your task container after you st ...
-
如果您想在左侧显示一个窗格,请使用'leading'作为区域的值然后在坎特区域,您将放置一个单独的边界容器,其中地图位于中心区域,而底部区域位于 ...实际上, resize()也是第一次工作,但你看不到发生任何事情,因为你应该在onClick发生后立即调用resize() ,但是在titlePane's调整大小动画结束后(默认情况下200毫秒),因为否则borderContainer调整为大小相同。 这是我的建议: dijit.byId("titlePane").watch("open", function(param, oldValue, newValue) { var animation = newValue ? this._wipeIn : ...@Nemi只需将BorderContainer的minHeight属性设置为0即可 。 @Nemi Just set the minHeight property of the BorderContainer to 0.是的,您可以在同一区域放置多个小部件,中心区域除外。 请注意,添加的第一个窗口小部件在区域指定的方向上最远。 第一个顶级小部件位于顶部。 第一个底部小部件位于底部,依此类推。 http://jsfiddle.net/cswing/ssDXh/ 看看你的例子,我建议将文本框和按钮放入它自己的内容窗格,然后将窗格放入bordercontainer。 bordercontainer将根据屏幕大小调整区域的大小,并且您不希望按钮和文本框更改大小。 编辑: 您可以考虑使用两种技术来完成评论中提到的内容。 1)您可以使 ...
相关文章
更多- Hadoop Operations
- Spring Data: a new perspective of data operations
- 如何对Hadoop作业的某个task进行debug单步跟踪
- Hadoop中的Speculative Task
- Storm-源码分析-Topology Submit-Task
- Storm【技术文档】-Worker Executor Task的关系
- 对Hadoop task进行profiling的几种方法整理
- 修改Linux Socket最大连接数
- Hadoop的task运行完成后清理local目录影响性能
- Hadoop的task运行完成后清理local目录影响性能
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。