473,748 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mutex gets ObjectDisposedE xception

I have various processes that are all logging to the same file using the same
function. In order to ensure nobody logs at the same time, I am using mutex.
The code I am using is listed below:

mut.WaitOne()
Dim l_fstream As New StreamWriter(l_ logfile, True)
l_fstream.Write Line(stringtolo g)
l_fstream.Flush ()
l_fstream.Close ()
mut.ReleaseMute x()

The code seems to work fine, except every now and then I get an
ObjectDisposedE xception. To recover from this exception, inside a catch
statement I am setting mut to a new mutex. I searched my code and other than
declaring Mut in the beginning of the class, I am not accessing Mut in any
other ways.

Does anybody have any idea what would cause the mutex to get disposed? I
have a workaround, but I'm really trying to find the root cause to this
exception.

Thanks!
Jul 22 '05 #1
0 1297

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4408
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with SharedMemAccess_Mutex_ctypes.py or SharedMemAccess_Mutex_win32all.py
5
3803
by: Ken Varn | last post by:
I have a named mutex object that is accessed by both an asp.net application and a Windows executable .net application. The Windows executable runs under the administrator logon, while the asp.net application runs under the standard asp.net user account. The problem relates to permissions on creation of the mutex. If the asp.net application creates the mutex, the executable cannot access it (access denied error). Likewise, if the...
2
4778
by: Martin Maat | last post by:
Hi. I want to use the same mutex in different classes (web pages in an ASP.NET application). In global.asax.cs, the class that starts up first, I create a Mutex like this: static private Mutex mtxBezoeken = new Mutex(false, "bezoeken"); which compiles and executes just fine. Then in another page I want to write to a file that may also be accessed by global.asax.cs so I want access to
17
435
by: Mark Rae | last post by:
Hi, I have a WinForms desktop MDI application written in C#. Following advice from others in this forum, I prevent multiple instances of the app running at the same time by creating / trying to create a mutex, as follows: bool blnCreatedMutex; objMutex = new System.Threading.Mutex(true, "zzzzzzMyCoolAppzzzzz", out blnCreatedMutex); if (!blnCreatedMutex)
16
3159
by: Ed Sutton | last post by:
I use a mutex to disallow starting a second application instance. This did not work in a release build until I made it static member of my MainForm class. In a debug build, first instance got ownership, second did not and terminated. In a release build, the second instance *also* got ownership. I "fixed" it by making the mutex a static member of my MainForm class. Did the garbage collector eat my mutex because it is not referenced
16
3364
by: mfdatsw1 | last post by:
I need to be certain my application only runs once on a machine, and I implemented a solution using Mutex. The solution was posted many times, but one great link I found is http://www.yoda.arachsys.com/csharp/faq/#one.application.instance The problem is, when I switch users (XP Professional) the second user can open a second instance of the application! How can I prevent this? Here's the relevant part of my code:
0
314
by: TomPel | last post by:
I have various processes that are all logging to the same file using the same function. In order to ensure nobody logs at the same time, I am using mutex. The code I am using is listed below: mut.WaitOne() Dim l_fstream As New StreamWriter(l_logfile, True) l_fstream.WriteLine(stringtolog) l_fstream.Flush() l_fstream.Close() mut.ReleaseMutex()
2
6232
by: tony.newsgrps | last post by:
Hi there, I'm trying to understand the impact of killing a process that owns a system mutex (used to ensure there is only 1 instance of my program running) Here is my code pretty much: try { mutex=new System.Threading.Mutex( true, mutexName, out createdNew)
7
3043
by: tiffini | last post by:
Hi, We have a lot of OS's to support. So we created a mutex class with sieze and release like so class foo{ private: volatile int m_lock; public:
0
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9253
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6077
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2216
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.