Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Mutex

Here is a simple mutex that I coded pretty self explanatory

Declare:
Code
Private check As Mutex

Sub:
Code
Private Sub checkifopen(ByVal mute As String)
  Try
    System.Threading.Mutex.OpenExisting(mute)
    Me.Close()
  Catch ex As Exception
    check = New System.Threading.Mutex(False, mute)
    Exit Sub
  End Try
End Sub

How to Use:
Code
checkifopen("Mutex Here")
sorry for the noob question but what is a mutex :$?
sub is screwed up

Code
Private Sub checkifopen(ByVal mute As String)
  Try
    System.Threading.Mutex.OpenExisting(mute)
    Me.Close()
  Catch ex As Exception
    check = New System.Threading.Mutex(False, mute)
  End Try
    End Sub
fixed

also it would be better if you
Code
Private check As Mutex
Private Sub checkifopen(ByVal mute As String)
  Try
    Messagebox.Show(System.Threading.Mutex.OpenExisting(mute))
    Catch ex As Exception
  check = New System.Threading.Mutex(False, mute)
  messagebox.show(ex.message)
  End Try
End Sub
(Aug 2, 2010 10:22 AM)grimd34th Wrote:  sub is screwed up

Code
Private Sub checkifopen(ByVal mute As String)
  Try
    System.Threading.Mutex.OpenExisting(mute)
    Me.Close()
  Catch ex As Exception
    check = New System.Threading.Mutex(False, mute)
  End Try
    End Sub
fixed

also it would be better if you
Code
Private check As Mutex
Private Sub checkifopen(ByVal mute As String)
  Try
    Messagebox.Show(System.Threading.Mutex.OpenExisting(mute))
    Catch ex As Exception
  check = New System.Threading.Mutex(False, mute)
  messagebox.show(ex.message)
  End Try
End Sub

I didnt put message boxes because i didnt want the user to see anything. Oh and you removed exit sub, but it still works with it.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Iera NamhorunFeb 14, 2019 11:39 PM 10 420 Feb 14, 2019 11:39 PM
Last Post: Iera Namhorun
[C] by GoodiesSep 11, 2016 11:53 PM 2 229 Sep 11, 2016 11:53 PM
Last Post: Goodies
[.NET] by fredde_jasonJul 29, 2015 06:28 PM 19 1,114 Jul 29, 2015 06:28 PM
Last Post: The Scarabian