I need to raise an event without blocking the calling method, what is the way to do it?
1) Start a task and raise the event from within the task? :
//Body of listener function above
if (EventFound)
Task.Factory.StartNew(() =>
{
SendEvent();
});
2) Start a task from within the eventhandler:
public void OnEventRaised(....)
{
Task.Factory.StartNew(() =>
{
//Do lengthy stuff here
});
}
Does either block the calling function?