Click here to Skip to main content
15,611,246 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

Lets say i have application and both are using one common resource lets say a text file,how can i synchronize these two application for exception.

Sergey Alexandrovich Kryukov 29-Sep-13 2:46am    
What does it mean, "synchronize for exception"?
tasumisra 29-Sep-13 12:18pm    
not exactly exception..its kind of exception prevention
Sergey Alexandrovich Kryukov 29-Sep-13 22:49pm    
It was your word about exception. Synchronization is not really prevention of exception, it is preventing something worse than exceptions. The code may work incorrectly without a single exception, so nothing would indicate incorrectness, and this can happen due to wrong or missing synchronization. Misuse of synchronization may cause deadlocks (among other bad things), and wrong synchronization or lack if it may cause such bad thing as race condition. Please read on those concepts, as knowing them is very important.
BillWoodruff 29-Sep-13 4:26am    
By "synchronize" I assume you mean something more than preventing one application from accessing the file while it's open in the other application ... right ?
tasumisra 29-Sep-13 12:18pm    

1 solution

You can use a named mutex:[^].

As all processes are isolated and run in their separate memory spaces, you need some shared synchronization object. Such sharing is achieved through giving some objects identical names. Please see:[^].

Use the constructors using the mutex name; it will allow them to act as an IPC device shared by both processes.
See also:[^].

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900