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

Glossary Item Box

Represents a single worker thread that processes IWaitAndContinue work items

Syntax

Visual Basic (Declaration) 
Public Class WaitAndContinueWorker 
C# 
public class WaitAndContinueWorker 

Example

Library/Library.Test/TestWaitAndContinue.cs

C#Copy Code
using (WaitAndContinueWorker work = new WaitAndContinueWorker())
{
    SampleWork item = new SampleWork();
    item.WorkThrows = true;
    work.AddWork(item);

    ManualResetEvent mreError = new ManualResetEvent(false);
    Exception error = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { error = e.GetException(); mreError.Set(); };

    item.Ready.Set();
    Assert.IsTrue(mreError.WaitOne(1000, false));
    Assert.IsTrue(error is ArgumentOutOfRangeException);
    Assert.IsTrue(((ArgumentOutOfRangeException)error).ParamName == "WorkThrows");
}
VB.NETCopy Code
Using work As New WaitAndContinueWorker()
    Dim item As New SampleWork()
    item.WorkThrows = True
    work.AddWork(item)

    Dim mreError As New ManualResetEvent(False)
    Dim [error] As Exception = Nothing
    work.OnError += Function(o As Object, e As ErrorEventArgs) Do
        [error] = e.GetException()
        mreError.[Set]()
    End Function

    item.Ready.[Set]()
    Assert.IsTrue(mreError.WaitOne(1000, False))
    Assert.IsTrue(TypeOf [error] Is ArgumentOutOfRangeException)
    Assert.IsTrue((DirectCast([error], ArgumentOutOfRangeException)).ParamName = "WorkThrows")
End Using

Inheritance Hierarchy

System.Object
   CSharpTest.Net.Threading.WaitAndContinueWorker

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys