CSharpTest.Net
Abort Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class : Abort Method

Glossary Item Box

Terminates all work by aborting the worker thread even if work is in progress

Syntax

Visual Basic (Declaration) 
Public Sub Abort() 
C# 
public void 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.NETCopy 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

Generated with Document! X 2011 by Innovasys