home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / nivb_src / sync.frm < prev    next >
Text File  |  1993-06-03  |  3KB  |  93 lines

  1. VERSION 2.00
  2. Begin Form SyncForm 
  3.    Caption         =   "Synchronization Services Test"
  4.    Height          =   3045
  5.    Left            =   1035
  6.    LinkTopic       =   "Form1"
  7.    ScaleHeight     =   2640
  8.    ScaleWidth      =   6705
  9.    Top             =   1140
  10.    Width           =   6825
  11.    Begin Timer SyncTimer 
  12.       Interval        =   1000
  13.       Left            =   360
  14.       Top             =   1680
  15.    End
  16.    Begin CommandButton CancelButton 
  17.       Caption         =   "&Cancel"
  18.       Height          =   495
  19.       Left            =   2640
  20.       TabIndex        =   0
  21.       Top             =   2040
  22.       Width           =   1095
  23.    End
  24.    Begin Label Label2 
  25.       Caption         =   "Run NWTEST at least 4 times (on this or multiple workstations) and select ""Synchronization"" from the Test menu. The  current user count will be updated every second."
  26.       Height          =   615
  27.       Left            =   120
  28.       TabIndex        =   3
  29.       Top             =   720
  30.       Width           =   6375
  31.    End
  32.    Begin Label Label1 
  33.       Caption         =   "Scenario:  There is a resource on the network (a program, for example) that you want to restrict to 3 simultaneous users."
  34.       Height          =   495
  35.       Left            =   120
  36.       TabIndex        =   2
  37.       Top             =   120
  38.       Width           =   6495
  39.    End
  40.    Begin Label CountLabel 
  41.       Height          =   255
  42.       Left            =   1800
  43.       TabIndex        =   1
  44.       Top             =   1560
  45.       Width           =   2895
  46.    End
  47. End
  48. Dim semaHandle&
  49. Const SEMA_VALUE = 3
  50. Dim exiting%
  51.  
  52. Sub CancelButton_Click ()
  53.     Unload SyncForm
  54. End Sub
  55.  
  56. Sub Form_Load ()
  57.     exiting% = False
  58.     ccode% = OpenSemaphore("VB_SYNCH_EXAMPLE", SEMA_VALUE, semaHandle&, openCount%)
  59.     If (ccode% <> SUCCESSFUL) Then
  60.         MsgBox "Unable to open semaphore", MB_OK, "Error"
  61.         Unload SyncForm
  62.     End If
  63.  
  64.     If (openCount% > SEMA_VALUE) Then
  65.         MsgBox "Unable to add another user.  Network resource is already in use by " + Str$(openCount% - 1) + " users", MB_OK, "Warning"
  66.         exiting% = True
  67.     Else
  68.         CountLabel.Caption = "Current user count = " + Str$(openCount%)
  69.     End If
  70. End Sub
  71.  
  72. Sub Form_Unload (Cancel As Integer)
  73.     ccode% = CloseSemaphore(semaHandle&)
  74. End Sub
  75.  
  76. Sub SyncTimer_Timer ()
  77.     If (exiting%) Then
  78.         Unload SyncForm
  79.     Else
  80.         ccode% = ExamineSemaphore(semaHandle&, SEMA_VALUE, openCount%)
  81.         If (ccode% <> SUCCESSFUL) Then
  82.             MsgBox "Unable to examine semaphore value.", MB_OK, "Error"
  83.         End If
  84.  
  85.         CountLabel.Caption = "Current user count = " + Str$(openCount%)
  86.     End If
  87. End Sub
  88.  
  89. Sub Timer1_Timer ()
  90.     
  91. End Sub
  92.  
  93.