Reputation: 31313
I have the following code that processes an INotification (custom interface)
var mgr = new NotificationManager();
var task = new Task(() => mgr.Send(notification));
task.Start();
Problem is once the Task completes, I need to perform some cleanup on notification. What is the approach for doing this with the Task Parallel library?
Upvotes: 1
Views: 325
Reputation: 16121
You can provide a multi-statement lambda:
Task.Factory.StartNew(() => { mgr.Send(notification); Cleanup(); };
Upvotes: 4
Reputation: 3996
You can do this using ContinueWith
. Here is the documentation ContinueWith
Upvotes: 4