Understanding SAO and CAO Activation Methods in .NET Remoting
page 5 of 9
by Abhishek Kumar Singh
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 40787/ 71

SAO Client implementation for both SAO-SingleCall/Singleton

Listing 5: Module1.vb for remote client

Module Module1
    Sub Main()
        Dim oClientService As New ClientService
        oClientService.OnStart()
        Console.Read()
    End Sub
End Module

Listing 6: ClientService.vb for remote client

Imports System.Data
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http
 
Public Class ClientService
 
    Private m_oTmrSend As System.Threading.Timer
    Private m_oRemote As ILibrary.IServer
    Private oChannel As HttpChannel = Nothing
    Private m_iTimeInterval As Integer
    Private m_Busy As Boolean = False
  
    Public Sub OnStart()
 
        oChannel = New HttpChannel(0)
        ChannelServices.RegisterChannel(oChannel, False)
 
        m_oRemote = Activator.GetObject(GetType(ILibrary.IServer), _
     "http://" & "localhost:1" & "/TestRemoteServer")
 
        Console.WriteLine(" Remote Client Started at " & Now.ToString())
 
        Console.WriteLine("CLIENT_A :: Channel Registered :" & _
          oChannel.ChannelName)
        Dim timerDelegate As Threading.TimerCallback = AddressOf DoAction
        m_oTmrSend = New System.Threading.Timer(timerDelegate, Me, 0, 10000)
    End Sub
    Public Sub DoAction(ByVal sender As Object)
Console.WriteLine("Received from Server: " & _
   m_oRemote.GetServerMessage("Client_A"))
 
     End Sub
 
    Protected Overrides Sub Finalize()
        MyBase.Finalize()
        ChannelServices.UnregisterChannel(oChannel)
        Console.WriteLine("CLIENT_A :: Channel Unregistered :: " & Now.ToString())
 
    End Sub
End Class

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-25 3:15:11 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search