使用Scheduler时是否有类似Dispatcher.CheckAccess()的东西

时间:2015-07-10 21:03:58

标签: system.reactive scheduler dispatcher

我想做相同的事情:

if (dispatcher.CheckAccess())
{
    // invoke synchronously if we are on the dispatcher thread
    collectionChangedEventHandler(this, args); 
}
else
{
    dispatcher.BeginInvoke(new Action(() => collectionChangedEventHandler(this, args)));
}

我还没有找到使用IScheduler

的方法

我想要的伪代码:

if (scheduler.CheckAccess())
{
    collectionChangeEventHandler(sender, args);
}
else
{
    scheduler.Schedule(() => collectionChangeEventHandler(sender, args));
}

CurrentThreadScheduler.ScheduleRequired看起来很有希望,但文档很少。

1 个答案:

答案 0 :(得分:1)

不,但您可以编写自己的2015/07/11 15:58:34 [error] 2857#0: *374 FastCGI sent in stderr: "PHP message: PHP Warning: mysqli::real_connect(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /srv/www/test.php on line 15 PHP message: PHP Warning: mysqli::real_connect(): Cannot connect to MySQL by using SSL in /srv/www/test.php on line 15 PHP message: PHP Warning: mysqli::real_connect(): [2002] (trying to connect via tcp://192.168.130.123:42139) in /srv/www/test.php on line 15 PHP message: PHP Warning: mysqli::real_connect(): (HY000/2002): in /srv/www/test.php on line 15"..... 来装饰CheckAccessDispatcherScheduler

https://github.com/Reactive-Extensions/Rx.NET/blob/master/Rx.NET/Source/System.Reactive.Windows.Threading/Reactive/Concurrency/DispatcherScheduler.cs

DispatcherScheduler