Announcement

Collapse
No announcement yet.

plugin connection loop vs disconnected event

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    plugin connection loop vs disconnected event

    Seems like all the templates and examples have a Connection State Loop that looks like this:

    Code:
    Do
         Threading.Thread.Sleep(30)
    Loop While client.CommunicationState = HSCF.Communication.Scs.Communication.CommunicationStates.Connected _
         And Not IsShuttingDown
    Why? Why not simply react to the ScsServices.Client Disconnect Event Like this:
    Code:
    Public WithEvents client As HSCF.Communication.ScsServices.Client.IScsServiceClient(Of IHSApplication)
    ...
    ...
    Private Sub Client_Disconnected(ByVal sender As Object, ByVal e As System.EventArgs) _
        Handles client.Disconnected
        Disconnect() '// Run the Disconnect cleanup code
        RaiseEvent ConnectionMessages(eHS3ConnectionMessageType.Disconnected, "Disconnected from Server")
    End Sub
    Must be a reason...but I can't figure it out! But from a programming cleanliness perspective, I do hate an endless loop with a yielding sleep function.

    Thoughts?

    #2
    Perhaps a long day at work is not best to think about this but if you don't loop something in a console app won't it just end?

    Comment


      #3
      Originally posted by mrhappy View Post
      Perhaps a long day at work is not best to think about this but if you don't loop something in a console app won't it just end?
      Ha - on the other hand perhaps my absence of a long day made me brain dead when I asked the question! The reason I got bogged down in this is because I was abstracting all the horrible plugin stuff into a dll...you are quite right --- the loop is there because it is/was a console app!

      So, I have removed it and use the disconnect event to catch if HS3 releases the plugin. Working fine. Now onto capturing events!

      Comment

      Working...
      X