I don't know where is the wrong , when some condition is meet i'm throwing exceptions, that catch should throw outside of another catch, normal scenario its happening but when i'm using task in anonymous function that is not happening.
private void button1_Click(object sender, EventArgs e)
{
try
{
tokenSource = new CancellationTokenSource();
Task t1 = Task.Run(() =>
{
try
{
while (true)
{
if (tokenSource.Token.IsCancellationRequested)
throw new OperationCanceledException();
}
}
catch (OperationCanceledException ex)
{
throw new OperationCanceledException();
}
}, tokenSource.Token);
Task task = Task.Run(() => getfristMethod(), tokenSource.Token);
}
catch (OperationCanceledException ee)
{
}
catch (AggregateException ee)
{
}
catch (OperationAbortedException eee)
{
}
}