CSharpTest.Net
StopAsyncSending Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : StopAsyncSending Method

completeWork
timeout

Glossary Item Box

Shutsdown the worker thread created by a call to EnableAsyncSend() allowing up to the number of milliseconds in timeout to shutdown the worker and complete any pending work. If timeout is 0, the worker will be aborted.

Syntax

Visual Basic (Declaration) 
Public Sub StopAsyncSending( _
   ByVal completeWork As Boolean, _
   ByVal timeout As Integer _
) 
C# 
public void StopAsyncSending( 
   bool completeWork,
   int timeout
)

Parameters

completeWork
timeout

Example

Library/Library.Test/TestIpcChannel.cs

C#Copy Code
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");

    ManualResetEvent ready = new ManualResetEvent(false);
    ManualResetEvent die = new ManualResetEvent(false);
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e)
    {
        ready.Set();
        die.WaitOne();
        Thread.CurrentThread.Abort();
    };

    sender.Broadcast(100, "Message");
    Assert.IsTrue(ready.WaitOne(1000, false));

    sender.EnableAsyncSend();
    sender.Broadcast(0, "Message");
    die.Set();
    sender.StopAsyncSending(true, 1000);
    ch1.StopListening();
}
VB.NETCopy Code
Using ch1 As New IpcEventChannel(_registrar, _channel)
    Using sender As New IpcEventChannel(_registrar, _channel)
        ch1.StartListening("ch1")

        Dim ready As New ManualResetEvent(False)
        Dim die As New ManualResetEvent(False)
        ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
            ready.[Set]()
            die.WaitOne()
            Thread.CurrentThread.Abort()
        End Function

        sender.Broadcast(100, "Message")
        Assert.IsTrue(ready.WaitOne(1000, False))

        sender.EnableAsyncSend()
        sender.Broadcast(0, "Message")
        die.[Set]()
        sender.StopAsyncSending(True, 1000)
        ch1.StopListening()
    End Using
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