Visual Basic (Declaration) | |
---|---|
Public Overloads Sub AddWork( _ ByVal item As IWaitAndContinue _ ) |
C# | |
---|---|
public void AddWork( IWaitAndContinue item ) |
Parameters
- item
Exception | Description |
---|---|
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object. |
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 |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7