开发者

EventAggregator with MultiThreads

I am having a little problem with the IEventAggregator, let me explain

public class doSomething
{
    public doSomething()
    {
        Action<AddEvent> GetAddSolution = s => this开发者_JAVA技巧.Add(s.a, s.b);
        IEventAggregator.GetEvent<AddEvent>().Subscribe(GetAddSolution);
    }

    public void Add(int a, int b)
    {
        IEventAggregator.GetEvent<AddSolutionEvent>().Publish(new AddSolutionEventArgs(a + b));
    }
}

Let above be a Demo service, in my case it is a long running one, now if i have multiple threads calling Add(a,b) using the EventAggrigator, the last thread which published request gets all the responses

how do i return response to the thread which published the request event.

Please Provide Guidance.

Thank you in Advance.


Got the answer my self, its simple, using event Filters in eventaggregator. the filter delegate filters the events.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜