You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
54
mcs/tests/test-async-78.cs
Normal file
54
mcs/tests/test-async-78.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public static class ExceptionHelper
|
||||
{
|
||||
public static async Task ConditionalCatchExceptThreadAbortAsync (Func<Task>
|
||||
funcTask, Action<Exception> conditionalCatchAction)
|
||||
{
|
||||
funcTask ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
class ATask
|
||||
{
|
||||
readonly object _asyncTaskCancellationSource = new object ();
|
||||
|
||||
readonly object aname;
|
||||
|
||||
public async Task<bool> OnDoWorkAsync ()
|
||||
{
|
||||
await ExceptionHelper.ConditionalCatchExceptThreadAbortAsync (
|
||||
async () => {
|
||||
if (_asyncTaskCancellationSource != null) {
|
||||
string item = null;
|
||||
|
||||
await ExceptionHelper.ConditionalCatchExceptThreadAbortAsync (
|
||||
async () => {
|
||||
Console.WriteLine (aname);
|
||||
},
|
||||
(e) => {
|
||||
Console.WriteLine (item);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
null
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class Tests
|
||||
{
|
||||
public static void Main ()
|
||||
{
|
||||
var a = new ATask ();
|
||||
var res = a.OnDoWorkAsync ().Result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user