Jump to content

Recommended Posts

Posted

Hi!

I've been wanting to synchronize multiple writer processes, all of which write some data into one file. But I've been unable to do so. Usually the error is that the processes are unable to access the object and sometimes an error occurs saying that "Handle is invalid".

I don't think the code is required for this. If someone could demonstrate a working method, that would be enough.

Could someone help me out?

Thanks

Posted

Hi!

I've been wanting to synchronize multiple writer processes, all of which write some data into one file. But I've been unable to do so. Usually the error is that the processes are unable to access the object and sometimes an error occurs saying that "Handle is invalid".

I don't think the code is required for this. If someone could demonstrate a working method, that would be enough.

Could someone help me out?

Thanks

A simple example for semaphores.

#Include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

If Not @Compiled Then
    MsgBox(0, '', 'To run this script, you must first compile it and then run the (.exe) file.')
    Exit
EndIf

Global $hSemaphore = _WinAPI_CreateSemaphore('MySemaphore', 2, 2)

_WinAPI_WaitForSingleObject($hSemaphore)
_MyGUI()
_WinAPI_ReleaseSemaphore($hSemaphore)
_WinAPI_FreeHandle($hSemaphore)

Func _MyGUI()

    Local $Msg

    GUICreate('MyGUI')
    GUISetState()
    While 1
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_MyGUI

WinAPIEx.au3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...