Hi,
I have a shared function which can only be called once if it is called at the same time in a program, it would produce error. How can avoid this?
thanks
Printable View
Hi,
I have a shared function which can only be called once if it is called at the same time in a program, it would produce error. How can avoid this?
thanks
A crude solution would be to use a global boolean variable set to false. The function first checks if it is still false then runs and sets it to true. After that it won't execute again.
-----------
Edit: I read your question more carefully, set it to true while the functions executes and at the end set it back to false.
How about using a SyncLock object?