Terminates all work by aborting the worker thread even if work is in progress
Syntax
Visual Basic (Declaration) | |
---|
Public Sub Abort() |
Example
Library/Library.Test/TestWaitAndContinue.cs
C# | Copy Code |
---|
using (WaitAndContinueWorker work = new WaitAndContinueWorker())
{
work.OnError += delegate(object o, ErrorEventArgs e) { throw new Exception("Failed.", e.GetException()); };
SampleWork item = new SampleWork();
item.SleepForever = true;
work.AddWork(item);
item.Ready.Set();
Assert.IsTrue(item.Sleeping.WaitOne(1000, false));
work.Abort();
Assert.IsFalse(item.Completed);
Assert.IsTrue(item.Disposed);
} |
VB.NET | Copy Code |
---|
Using work As New WaitAndContinueWorker()
work.OnError += Function(o As Object, e As ErrorEventArgs) Do
Throw New Exception("Failed.", e.GetException())
End Function
Dim item As New SampleWork()
item.SleepForever = True
work.AddWork(item)
item.Ready.[Set]()
Assert.IsTrue(item.Sleeping.WaitOne(1000, False))
work.Abort()
Assert.IsFalse(item.Completed)
Assert.IsTrue(item.Disposed)
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also