Trying to call a method that requires parameters in order to get a result and pass the result to proceed. But I'm new to the Task area and can't seem to figure out the correct syntax. Any help would be appreciated.
Task.Factory.StartNew(() =>
CheckConflict(startDate, endDate, actID, repeatRule,whichTime))
.ContinueWith(
GetConflictDelegate(result),
TaskScheduler.FromCurrentSynchronizationContext);
Assuming you want to continue with the result of CheckConflict()
, ContinueWith
takes a Task<T>
as an argument. Task<T>
has a property Result
, which will be the result from the method invocation.
See my code snippet below, for an example.
new TaskFactory()
.StartNew(() =>
{
return 1;
})
.ContinueWith(x =>
{
//Prints out System.Threading.Tasks.Task`1[System.Int32]
Console.WriteLine(x);
//Prints out 1
Console.WriteLine(x.Result);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With