Visual Basic (Declaration) | |
---|---|
Public Class WaitAndContinueWorker |
C# | |
---|---|
public class WaitAndContinueWorker |
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.NET | Copy 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 |
System.Object
CSharpTest.Net.Threading.WaitAndContinueWorker
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7