ThreadStart.BeginInvoke引发NotSupportedException在紧凑型框架 [英] ThreadStart.BeginInvoke throws NotSupportedException on Compact framework

查看:248
本文介绍了ThreadStart.BeginInvoke引发NotSupportedException在紧凑型框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我带螺纹的紧凑型框架项目工作,有code,看起来像下面。当我尝试步入StartThreads(),NotSupportedException异常被抛出。这似乎有些奇怪,为什么就行调用StartThreads()抛出的异常,而不是里面,那是什么不是支持CF呢?我认为它ThreadStart.BeginInvoke但是这不是其中的例外实际上是被抛出。

 无效的someMethod()
{
  this.StartThreads(); //<  - 引发NotSupportedException这里扔,我不能踏进这个方法与调试
}

无效StartThreads()
{
  的ThreadStart的ThreadStart = BeginDoStuff;
  threadStart.BeginInvoke(EndDoStuff,NULL);
}
 

解决方案

不支持CF <打击>的BeginInvoke的机制,以及线程池

您没有看到您所期望的异常的原因是由于该实现方式。我不能完全肯定的细节,但BeginInvoke的是不是一个正常的方法,但一些在运行时注入(Delegate类的)(只是猜测,最后一部分)。

在JIT编译器开始工作的StartThreads方法时发生错误。

I'm working with threads on a compact framework project and have code that looks something like below. When I try to step into StartThreads(), a NotSupportedException is thrown. This seems a bit wierd, why is the exception thrown on the line calling StartThreads() and not inside, and what is it that's not supported on CF? I think its ThreadStart.BeginInvoke but that's not where the exception is actually being thrown.

void SomeMethod()
{
  this.StartThreads(); // <- NotSupportedException is thrown here, I can't step into this method with the debugger
}

void StartThreads()
{
  ThreadStart threadStart = BeginDoStuff;
  threadStart.BeginInvoke(EndDoStuff, null);
}

解决方案

The BeginInvoke mechanism is not supported in CF, along with the ThreadPool.

The reason you don't see the Exception where you expect is due to the way this is implemented. I am not totally sure about the details but BeginInvoke is not a normal method (of the Delegate class) but something that is injected at runtime (just guessing that last part).

The error occurs when the JIT compiler gets to work on the StartThreads method.

这篇关于ThreadStart.BeginInvoke引发NotSupportedException在紧凑型框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆