Commit ad9ffa46 authored by Marc Gravell's avatar Marc Gravell

Test the "deny exec-sync" delegates before trusting them

parent 5a994a1b
......@@ -53,6 +53,18 @@ static TaskSource()
il.Emit(OpCodes.Ceq); // [true/false]
il.Emit(OpCodes.Ret);
IsSyncSafe = (Func<Task, bool>)method.CreateDelegate(typeof(Func<Task, bool>));
// and test them (check for an exception etc)
var tcs = new TaskCompletionSource<int>();
denyExecSync(tcs.Task);
if(!IsSyncSafe(tcs.Task))
{
Debug.WriteLine("IsSyncSafe reported false!");
Trace.WriteLine("IsSyncSafe reported false!");
// revert to not trusting them
denyExecSync = null;
IsSyncSafe = null;
}
}
}
catch(Exception ex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment