Software Components

Site Search      

  Home     Products     Demos     Support     Customers     FAQ's     Links     Contact Us


ActiveX Control Asynchronous Versus Synchronous Code Comparison

The table below shows equivalent code using the asynchronous and synchronous programming models.

The synchronous model can be simpler to design and implement in most cases, however, under adverse conditions such as communications timeouts, the application's user interface can be affected.

The asynchronous model can be more complex to design and implement, however, under adverse conditions such as communications timeouts, the application's user interface is not affected.

The code example shown below is based on our Modbus/TCP ActiveX Control.

Asynchronous Code Example Synchronous Code Example
' A timer is used to sequence through multiple sequential transactions.

Private Sub Timer1_Timer()
  ' If Busy try again at next timer tick
  If ASMBTCP1.Busy = True Then Exit Sub

  Select Case ASMBTCP1.Tag
    Case 0:
      ' Idle
      Exit Sub
    Case 1:
      ' Set starting memory location for transaction
      ASMBTCP1.MemStart = "1"
    Case 2:
      ' Set starting memory location for transaction
      ASMBTCP1.MemStart = "201"
  End Select
  ' Start the transaction
  ASMBTCP1.AsyncRefresh
End Sub

' Complete event fires when transaction has completed. At this point, transaction result should be checked and data processed if successful.

Private Sub Asmbtcp1_Complete(ByVal Result As Integer)
  'Test result
  If Result = 0 Then
    Select Case ASMBTCP1.Tag
    Case 1:
      ' Extract data
      Text1 = ASMBTCP1.DataWord(0)
      ASMBTCP1.Tag = 2
    Case 2:
      ' Extract data
      Text2 = ASMBTCP1.DataWord(0)
      ASMBTCP1.Tag = 0
    End Select
  'ERROR
  Else
    Select Case ASMBTCP1.Tag
    Case 1:
      ' Implement error handler
      ASMBTCP1.Tag = 0
    Case 2:
      ' Implement error handler
      ASMBTCP1.Tag = 0
    End Select
  End If
End Sub

' No timer is required to sequence through multiple sequential transactions.

Private Sub ReadRegisters()
  ' Set starting memory location for transaction
  ASMBTCP1.MemStart = "1"
  ' Perform the transaction
  ASMBTCP1.SyncRefresh
  ' Test result
  If ASMBTCP1.Result = 0 Then
    ' Extract data
    Text1 = ASMBTCP1.DataWord(0)
  Else
    ' Implement error handler
  Endif

  DoEvents

  ' Set starting memory location for transaction
  ASMBTCP1.MemStart = "201"
  ' Perform the transaction
  ASMBTCP1.SyncRefresh
  ' Test result
  If ASMBTCP1.Result = 0 Then
    ' Extract data
    Text2 = ASMBTCP1.DataWord(0)
  Else
    ' Implement error handler
  Endif
End Sub

Home / Products / Demos / Support / Customers / FAQ's / Links / Contact Us / Search


Copyright © 1997-2008 Automated Solutions, Inc. All rights reserved. Information in this document is subject 
to change without notice. Other products and companies referred to herein are trademarks or registered 
trademarks of their respective companies or mark holders.
E-mail:
Site design by: net10 Internet Services Inc.

 

 

 

vs.net vb.net c#.net c++.net .net mmi hmi scada plc ocx activex vbx driver visual basic vb visual C++ delphi, c++ builder opc server opc client communications library c#.

allen-bradley a-b ab data highway dh dh+ df1 dh485 1747 1784 1785 1756 1769 kt ktx pktx pcmk ethernet tcp/ip 1747-uic 1761-net-eni enbt enet dhrio ethernet/ip cip csp ethernetip eip.

kf2 kf3 ke sst 5136-sd slc500 plc5 plc2 micrologix 1000 1100 1200 1500 rslinx aic aic+ pic controllogix rslogix softlogix 5800 rockwell intouch flexlogix processlogix compactlogix guardlogix 1756-L61 1756-L62 1756-L63 logix5550 logix5555 logix556x.

powerflex 160 160z 1305

modicon squared modbus rtu modbus ascii modbus plus modbus/tcp jbus memobus modconnect enron modbus sa-85 sa85 quantum momentum 984 wago schneider alliances altivar carriere inductel masterpact zelio collaborative automation powerlogic.

ge fanuc snpx 90/30 90/70 series90 series one srtp versamax pacsystems rx7i rx3i 90-70 90-30

plc direct automation direct directlogic dl05 dl06 dl105 dl205 dl305 dl305 dl240 dl250 dl260 dl330 dl340 dl350 dl430 dl440 dl450 ecom.

siemens simatic ti305 koyo sr21 omron toshiba idec. 

sixnet ethertrak remotetrak sixtrak versatrak sitetrak.

automation process visualization wonderware intouch topserver kepserver rsview rsview32 intellution ifix dynamics control dde linx logix

iconics enron rslinx cimplicity national instruments citect citecthmi wincc labview labwindows lookout.

thermoflow thermo flow automation automate autopilot benchmark flow computer.

omni omniflow omni flow computer omni 3000 omni 6000 bristol babcock 3305

acromag busworks 900en 951en 952en 061en 962en 963en 964en 965en 966en 972en 973en 981en 982en 983en

913mb 914mb 917mb 918mb 924mb 932mb 934mb 942mb

901mb 902mb 903mb 904mb 905mb 906mb

hms anybus moxa nport niobrara sealevel systems seai/o

auma riester aumatic

abb totalflow triatek e-link

control technology corporation blue fusion prosoft technology