home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / nivb / sync.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  2.8 KB  |  87 lines

  1. VERSION 2.00
  2. Begin Form SyncForm 
  3.    Caption         =   "Synchronization Services Test"
  4.    ClientHeight    =   2640
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   6705
  8.    Height          =   3045
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2640
  12.    ScaleWidth      =   6705
  13.    Top             =   1140
  14.    Width           =   6825
  15.    Begin Timer SyncTimer 
  16.       Interval        =   1000
  17.       Left            =   360
  18.       Top             =   1680
  19.    End
  20.    Begin CommandButton CancelButton 
  21.       Caption         =   "&Cancel"
  22.       Height          =   495
  23.       Left            =   2640
  24.       TabIndex        =   0
  25.       Top             =   2040
  26.       Width           =   1095
  27.    End
  28.    Begin Label Label2 
  29.       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."
  30.       Height          =   615
  31.       Left            =   120
  32.       TabIndex        =   3
  33.       Top             =   720
  34.       Width           =   6375
  35.    End
  36.    Begin Label Label1 
  37.       Caption         =   "Scenario:  There is a resource on the network (a program, for example) that you want to restrict to 3 simultaneous users."
  38.       Height          =   495
  39.       Left            =   120
  40.       TabIndex        =   2
  41.       Top             =   120
  42.       Width           =   6495
  43.    End
  44.    Begin Label CountLabel 
  45.       Height          =   255
  46.       Left            =   1800
  47.       TabIndex        =   1
  48.       Top             =   1560
  49.       Width           =   2895
  50.    End
  51. Dim semaHandle&
  52. Const SEMA_VALUE = 3
  53. Dim exiting%
  54. Sub CancelButton_Click ()
  55.     Unload SyncForm
  56. End Sub
  57. Sub Form_Load ()
  58.     exiting% = False
  59.     ccode% = OpenSemaphore("VB_SYNCH_EXAMPLE", SEMA_VALUE, semaHandle&, openCount%)
  60.     If (ccode% <> SUCCESSFUL) Then
  61.         MsgBox "Unable to open semaphore", MB_OK, "Error"
  62.         Unload SyncForm
  63.     End If
  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. Sub Form_Unload (Cancel As Integer)
  72.     ccode% = CloseSemaphore(semaHandle&)
  73. End Sub
  74. Sub SyncTimer_Timer ()
  75.     If (exiting%) Then
  76.         Unload SyncForm
  77.     Else
  78.         ccode% = ExamineSemaphore(semaHandle&, SEMA_VALUE, openCount%)
  79.         If (ccode% <> SUCCESSFUL) Then
  80.             MsgBox "Unable to examine semaphore value.", MB_OK, "Error"
  81.         End If
  82.         CountLabel.Caption = "Current user count = " + Str$(openCount%)
  83.     End If
  84. End Sub
  85. Sub Timer1_Timer ()
  86. End Sub
  87.