public static void SafeWaitHandleExtensions_get() { var wh = new MyWaitHandle(); var swh = wh.GetSafeWaitHandle(); Assert.Equal(new IntPtr(-1), swh.DangerousGetHandle()); }
public void CanCastWaitHandleToTask() { var waitHandle = new MyWaitHandle(); var task = waitHandle.ToTask(new CancellationToken()); task.Status.Should().NotBeNull(); }
public static void SafeWaitHandleExtensions_set() { var wh = new MyWaitHandle(); var swhExpected = new SafeWaitHandle(new IntPtr(5), true); wh.SetSafeWaitHandle(swhExpected); var swh = wh.GetSafeWaitHandle(); Assert.Equal(swhExpected, swh); wh.SetSafeWaitHandle(null); swh = wh.GetSafeWaitHandle(); Assert.NotNull(swh); Assert.Equal(new IntPtr(-1), swh.DangerousGetHandle()); }
public static void SafeWaitHandleExtensions_set() { var wh = new MyWaitHandle(); var swhExpected = new SafeWaitHandle(new IntPtr(5), true); wh.SetSafeWaitHandle(swhExpected); var swh = wh.GetSafeWaitHandle(); Assert.Equal(swhExpected, swh); wh.SetSafeWaitHandle(null); swh = wh.GetSafeWaitHandle(); Assert.NotNull(swh); Assert.Equal(new IntPtr(-1), swh.DangerousGetHandle()); // Prevent finalization. Closing of the bogus handle has unpredictable results. swhExpected.SetHandleAsInvalid(); }