Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I’m developing a module that has to handle many events coming from an external system. I’ve to use a third party class providing an event (OnNewMessage) passing some parameters as input and two as output, each event require a bunch of time in order to be processed. I’d like to serve these events in a parallel way, in order to avoid blocking the caller and to process multiple request in parallel.

Here an example of my code:

void Init()
{
   provider.OnNewMessage += new OnMessageEventHandler(processEvent);
}

void processEvent(string xml, int …, out string resultXML, out string description)
{
   ...
}

Which is the best approach to do this in C# 3.5?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

I would use a queue to store the events, and then consume that queue from a bounch of thread from the thread pool.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...