home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / NIVB_SRC / SYNC.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-06-03  |  2.7 KB  |  83 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. Dim semaHandle&
  48. Const SEMA_VALUE = 3
  49. Dim exiting%
  50. Sub CancelButton_Click ()
  51.     Unload SyncForm
  52. End Sub
  53. Sub Form_Load ()
  54.     exiting% = False
  55.     ccode% = OpenSemaphore("VB_SYNCH_EXAMPLE", SEMA_VALUE, semaHandle&, openCount%)
  56.     If (ccode% <> SUCCESSFUL) Then
  57.         MsgBox "Unable to open semaphore", MB_OK, "Error"
  58.         Unload SyncForm
  59.     End If
  60.     If (openCount% > SEMA_VALUE) Then
  61.         MsgBox "Unable to add another user.  Network resource is already in use by " + Str$(openCount% - 1) + " users", MB_OK, "Warning"
  62.         exiting% = True
  63.     Else
  64.         CountLabel.Caption = "Current user count = " + Str$(openCount%)
  65.     End If
  66. End Sub
  67. Sub Form_Unload (Cancel As Integer)
  68.     ccode% = CloseSemaphore(semaHandle&)
  69. End Sub
  70. Sub SyncTimer_Timer ()
  71.     If (exiting%) Then
  72.         Unload SyncForm
  73.     Else
  74.         ccode% = ExamineSemaphore(semaHandle&, SEMA_VALUE, openCount%)
  75.         If (ccode% <> SUCCESSFUL) Then
  76.             MsgBox "Unable to examine semaphore value.", MB_OK, "Error"
  77.         End If
  78.         CountLabel.Caption = "Current user count = " + Str$(openCount%)
  79.     End If
  80. End Sub
  81. Sub Timer1_Timer ()
  82. End Sub
  83.