单线程程序的C#事件订阅限制 [英] C# event subscription limits for single threaded programs

查看:165
本文介绍了单线程程序的C#事件订阅限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图监视在单个线程程序中并行运行的许多HPC作业的状态,我订阅的是OnJobState引发的事件,当监视多达三个作业时,事件状态更改将丢失并且作业卡住了.

I'm attempting to monitor the status of many HPC jobs running in parallel in a single threaded program, I'm subscribing to events raised by OnJobState and when monitoring as few as three jobs event state changes will go missing and the job is stuck running.

我假设每个工作都需要一个线程来捕获所有事件,但是我无法在单个线程程序中找到有关事件下标限制的任何信息.

I'm assuming I need a thread per job to catch all the events but I can't find any information about the limits of events subscripton in a single thread program.

我本以为.net平台会将所有这些排队,但事实并非如此.

I would have thought the .net platform would queue this all up but that doesn't appear to be the case.

推荐答案

我制作了这个问题更笼统地消除了对HPC的困惑,似乎我无法控制事件处理程序的执行方式,因此我需要使其变得线程安全.

I made this question more general to remove the confusion over HPC, looks like I have no control over how my event hander is executed so I need to make it thread safe.

这篇关于单线程程序的C#事件订阅限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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