- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我们的应用程序中,我们目前正转向 System.Threading.Tasks.Dataflow
来管理所有通信。但是现在每次我们在任何自定义 SynchronizationContext
中使用我们的网络客户端/服务器类时,我们都会得到一个异常。
"System.Threading.ExecutionContext doesn't implement interface System.IDisposable".
我不知道这怎么可能。我们从不更改或使用任何线程执行上下文。我们做的最接近它的是
SynchronizationContext.SetSynchronizationContext (new GtkSynchronizationContext ());
Scheduler = TaskScheduler.FromCurrentSynchronizationContext ();
Factory = new TaskFactory (Scheduler);
我不明白为什么自定义 SynchronizationContext
会使 DataFlow 像这样崩溃。以下是导致 DataFlow 异常的应用程序的输出。
madrang@Qosmio-X770:~$ '/home/madrang/WorkSpace/linsft/Source/Invensys/Build/runbuild'
Engine Initialize started
==============================================================================
Application Information
------------------------------------------------------------------------------
Program : /home/madrang/WorkSpace/linsft/Source/Invensys/Build/Bin/Linsft.Engine.dll
Time : 14/04/2013 04:46:02
User : madrang
Computer : Qosmio-X770
OS : Linux64
Processors : 8
Working Set : 0
Framework : 4.0.30319.1
Run Time : 00:00:01.6015700
------------------------------------------------------------------------------
Loaded Modules
------------------------------------------------------------------------------
/usr/bin/mono||0
/usr/bin/mono||3031040
/usr/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll|4.0.0.0|188416
/usr/lib/mono/gac/System.Runtime.Serialization/3.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll|3.0.0.0|196608
/usr/lib/mono/gac/System.ServiceModel/3.0.0.0__b77a5c561934e089/System.ServiceModel.dll|3.0.0.0|1396736
/usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll|4.0.0.0|1748992
/usr/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll|4.0.0.0|1273856
/usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll|4.0.0.0|798720
/home/madrang/WorkSpace/linsft/Source/Invensys/Build/Bin/NLog.dll|2.0.0.0|319488
/home/madrang/WorkSpace/linsft/Source/Invensys/Build/Bin/Mono.Addins.dll|1.0.0.0|237568
/home/madrang/WorkSpace/linsft/Source/Invensys/Build/Bin/Mono.Addins.Setup.dll|1.0.0.0|131072
/lib/x86_64-linux-gnu/libnss_files-2.17.so||49152
/lib/x86_64-linux-gnu/libnss_nis-2.17.so||45056
/lib/x86_64-linux-gnu/libnsl-2.17.so||94208
/lib/x86_64-linux-gnu/libnss_compat-2.17.so||32768
/usr/lib/mono/4.0/mscorlib.dll|4.0.0.0|2867200
/usr/lib/locale/locale-archive||2920448
/lib/x86_64-linux-gnu/libc-2.17.so||1826816
/lib/x86_64-linux-gnu/libpthread-2.17.so||98304
/lib/x86_64-linux-gnu/libdl-2.17.so||12288
/lib/x86_64-linux-gnu/librt-2.17.so||28672
/lib/x86_64-linux-gnu/libm-2.17.so||1060864
/lib/x86_64-linux-gnu/ld-2.17.so||143360
/usr/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll|4.0.0.0|126976
/home/madrang/WorkSpace/linsft/Source/Invensys/Build/Bin/Linsft.Engine.dll|0.5.4849.6350|36864
/home/madrang/WorkSpace/linsft/Source/Invensys/Build/Invensys.exe|1.0.4845.22748|8192
/run/shm/mono.8910||4096
------------------------------------------------------------------------------
Loaded Assembly
------------------------------------------------------------------------------
Mono.Posix, 4.0.0.0
System.Runtime.Serialization, 3.0.0.0
System.ServiceModel, 3.0.0.0
System, 4.0.0.0
System.Configuration, 4.0.0.0
System.Xml, 4.0.0.0
System.Core, 4.0.0.0
NLog, 2.0.0.0
Mono.Addins, 1.0.0.0
Mono.Addins.Setup, 1.0.0.0
Linsft.Engine, 0.5.4849.6350
Invensys, 1.0.4845.22748
mscorlib, 4.0.0.0
==============================================================================
Registed new scheduler: ThreadPool
Addin Loaded: Linsft.Engine
Assembly Loaded ICSharpCode.SharpZipLib, 2.84.0.0
Assembly Loaded Mono.Addins.CecilReflector, 1.0.0.0
Assembly Loaded Mono.CSharp, 4.0.0.0
Assembly Loaded NLog.Extended, 2.0.0.0
Assembly Loaded xunit, 1.9.1.1600
Assembly Loaded xunit.extensions, 1.9.1.1600
Assembly Loaded xunit.runner.utility, 1.9.1.1600
Addin Loaded: Linsft.Invensys
Starting new task in default scheduler: Linsft.CommandExtensionNode: Id=Linsft.Core.IdleScheduler.Initialize, Linsft.Core.IdleScheduler.Initialize()
Assembly Loaded Linsft.Core, 1.0.4850.6090
Assembly Loaded Linsft.Configuration, 0.0.0.1
Assembly Loaded Linsft.Network, 0.0.0.1
Assembly Loaded Linsft.Storage, 0.0.0.1
Assembly Loaded Linsft.Validator.Base, 1.0.0.22749
Assembly Loaded System.Threading.Tasks.Dataflow, 0.0.4303.21337
Assembly Loaded Ionic.Zip.Reduced, 1.9.1.8
Assembly Loaded Linsft.Helper, 1.0.4845.22748
Addin Loaded: Linsft.Core
Idle Scheduler Initialize
Idle Scheduler Started
Registed new scheduler: Idle
Starting pending task for: Idle
Scheduler Idle loaded, unlock Initialize
Assembly Loaded Mono.Security, 4.0.0.0
Starting new task in default scheduler: Linsft.CommandExtensionNode: Id=Linsft.Core.Gui.InitializeGtk, Linsft.Core.Gui.GtkScheduler.Initialize()
Addin Loaded: Linsft.Core.Gui
Assembly Loaded atk-sharp, 3.0.0.0
Assembly Loaded cairo-sharp, 1.10.0.0
Assembly Loaded gdk-sharp, 3.0.0.0
Assembly Loaded gio-sharp, 3.0.0.0
Assembly Loaded glib-sharp, 3.0.0.0
Assembly Loaded gtk-dotnet, 3.0.0.0
Assembly Loaded gtk-sharp, 3.0.0.0
Assembly Loaded pango-sharp, 3.0.0.0
Assembly Loaded Linsft.Core.Gui, 1.0.4850.6091
Gtk Scheduler Initialize
Scheduler not loaded, Will be started later: Linsft.CommandExtensionNode: Id=Linsft.Core.Gui.ShowMainWindow, Scheduler=Gtk, Linsft.Core.Gui.MainWindow.ShowWindow()
Gtk Scheduler Started
Starting new task in default scheduler: Linsft.CommandExtensionNode: Id=Linsft.Commander.Initialize, Linsft.Commander.Terminal.Initialize()
Addin Loaded: Linsft.Commander
Assembly Loaded Linsft.Commander, 1.0.4852.8576
Telnet server started: [ServicePoint: Address=tcp://127.0.0.1:8090/, ConnectionName=tcp, ConnectTimeout=15000, Port=8090]
Registed new scheduler: Gtk
Starting pending task for: Gtk
Building ExtendedWindow
Completed Building ExtendedWindow
Building MainWindow
Linsft.Core Opening Configuration Storage
Opening Container, Class=Linsft.Core.Configuration, Method=.cctor
Linsft.Core Configuration Loaded Sucessfully
MainWindow Width=800, Height=600
MainWindow X=65, Y=24
Completed Building MainWindow
Engine Initialize completed
TcpConnectionListener Connection Request: [ServicePoint: Address=tcp://127.0.0.1:8090/, ConnectionName=tcp, ConnectTimeout=15000, Port=8090]
Telnet client connected: [ServicePoint: Address=tcp://127.0.0.1:43544/, ConnectionName=tcp, ConnectTimeout=15000, Port=43544]
TcpConnectionListener received a new connection: [ServicePoint: Address=tcp://127.0.0.1:43544/, ConnectionName=tcp, ConnectTimeout=15000, Port=43544]
System.Threading.ExecutionContext doesn't implement interface System.IDisposable
Stacktrace:
at System.Threading.Tasks.Dataflow.Internal.Common.CreateCopyAndRun (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) <0x00071>
at System.Threading.Tasks.Dataflow.Internal.Common.InvokeCallbackWithContext (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) <0x0003b>
at System.Threading.Tasks.Dataflow.Internal.TargetCore`1.ProcessMessagesLoopWithExecutionContext () <0x0011f>
at System.Threading.Tasks.Dataflow.Internal.TargetCore`1.<ProcessAsyncIfNecessary_Slow>b__3 (object) <0x00033>
at System.Threading.Tasks.TaskActionInvoker/ActionObjectInvoke.Invoke (System.Threading.Tasks.Task,object,System.Threading.Tasks.Task) <0x00023>
at System.Threading.Tasks.Task.InnerInvoke () <0x0005c>
at System.Threading.Tasks.Task.ThreadStart () <0x001cf>
at System.Threading.Tasks.Task.Execute () <0x0000f>
at System.Threading.Tasks.TpScheduler.TaskExecuterCallback (object) <0x0004b>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>
Native stacktrace:
mono() [0x4961e9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfbd0) [0x7fbd34914bd0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7fbd34574037]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7fbd34577698]
mono() [0x5cdd7f]
mono() [0x5cde02]
mono() [0x497eaf]
mono() [0x4985c4]
[0x41751bba]
Debug info from gdb:
Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No threads.
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
/home/madrang/WorkSpace/linsft/Source/Invensys/Build/invensys: line 5: 8910 Aborted (core dumped) mono "$INVENSYSDIR/Invensys.exe"
在单声道上运行
madrang@Qosmio-X770:~$ mono --version
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-5ubuntu1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
欢迎提出任何想法,因为我现在开始阅读文档和代码的第二周,试图找到解决方案。
谢谢,马德兰
最佳答案
我怀疑您以某种方式引用了 .NET 4.0 之前的 ExecutionContext 版本。您会注意到在 .NET 4.0 之前,ExecutionContext 没有实现 IDisposable:
http://msdn.microsoft.com/en-us/library/system.threading.executioncontext(v=vs.90).aspx
上面显示您使用的是 .NET 4.0,但是您是否可以想到如何在您的应用程序中引入旧版本的 ExecutionContext
?您是否有机会使用 .NET 3.5 向后移植的 System.Threading.dll?用于响应式扩展?
我不是 mono 用户,但是 Mono 的 ExecutionContext
是否为 .NET 4.0 实现了 IDisposable
(哪里会我检查一下)?看看这个: https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Threading/ExecutionContext.cs
它显示它确实如此,但我不知道您使用的当前版本的单声道是否有该代码。
关于c# - System.Threading.ExecutionContext 没有实现接口(interface) System.IDisposable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16029512/
我有一个 .Net Framework 控制台应用程序,可以在 Azure 中成功将其发布为 WebJob 并查看它的运行情况。当我尝试向函数添加 ExecutionContext 参数时,我收到上述
我有以下测试用例: test("test future") { import scala.concurrent.ExecutionContext.global import scala
ExecutionContext 可用于函数参数。 但是,它不能通过依赖注入(inject)供其他方法使用,包括 Functions 的构造函数,如下所示: public class Func
ExecutionContext 可用于函数参数。 但是,它不能通过依赖注入(inject)供其他方法使用,包括 Functions 的构造函数,如下所示: public class Func
有人知道 ExecutionContext.Capture() 和 ExecutionContext.Run(context, work, state) 是否很昂贵吗? 它是否会降低性能,因此建议谨慎
我想知道哪个ExecutionContext我应该在 scalatest % 2.2.6 上使用(以及为什么)运行我的 future 并模拟 future 。 class Foo { def f
我一直在开发一个中小型 Web 应用程序,大约有 10 个端点。它应该可以同时处理数百个并发请求。 由于我公司的政策,我必须为我的 Controller 使用 javax.ws.rs,所以每个 Con
我有以下代码: object KafkaApi { private implicit val main: ExecutionContextExecutor = ExecutionContext.g
考虑以下代码: private static async Task Main(string[] args) { await SetValueInAsyncMethod(); Print
在每个方法中传递 ExecutionContext 是否更符合 Scala 习惯,例如 class Foo { def bar(a: Int, b: Int)(implicit ec: Exe
我试图发现 ExecutionContext实际上适用于 .NET Framework 4.0 及更高版本。文档说,在使用 Thread.Start 和大多数线程池操作时,托管原则、同步、区域设置和用
假设我想知道给定 ExecutionContext 中有多少个线程. 所以我正在写一个这样的函数 def count(implicit ec: ExecutionContext): Int = {
我知道,当您通过调用 BeginInvoke() 或 ThreadPool.QueueUserWorkItem(...) 并行运行某些方法时,.NET 框架正在捕获包含代码访问安全信息和其他一些内容的
在 scala 中使用 future 时,默认行为是使用默认的 Implicits.global 执行上下文。看来这默认为每个处理器提供一个可用线程。在更传统的线程 Web 应用程序中,当 futur
我有一个 Spring 批处理作业,它使用如下 Web 参数执行: https://localhost:8443/batch/async/orz003A?id=123&name=test 我已将这些参
我希望将隐式 ExecutionContext 传递给部分实现的特征。 在代码示例中: import scala.concurrent.Future trait Processor[T,R] {
我正在使用 Scala 2.10 future 创建一个异步库。库的构造函数采用一系列实现特定特征的用户定义对象,然后库类上的方法将一些数据逐个发送到用户定义对象中。我希望用户提供ExecutionC
这是一个相当笼统的问题,但希望是一个合理的问题。什么时候ExecutionContext#reportFailure(Throwable)叫? Scala 标准库中似乎没有调用它。我想我也许应该在某些
当我制作 future ,或应用类似 onSuccess 的方法和 map ,我可以为它们指定 ExecutionContext 。 例如, val f = future { // code }
我有这两个错误: Error:(39, 20) Cannot find an implicit ExecutionContext. You might pass an (implicit ec: Ex
我是一名优秀的程序员,十分优秀!