C
C#2mo ago
시큐우

WaitOne for EventWaitHandle makes program crash without error?

im using mutex and some events to sending some data to other program, but my program crashes completely after bool a = attachEvent0.WaitOne(waitTime); without any errors. it doesn't run the codes after :/ btw when the attachEvent0 is already signaled(turned on?), it works well without crashing,,,
No description
14 Replies
Omnissiah
Omnissiah2mo ago
can you catch that exception with a try/catch?
try{
bool b=nutex.WaitOne(waitTime);
bool a=attachEvent0.WaitOne(waitTime);
...
}catch(Exception e)
{}
try{
bool b=nutex.WaitOne(waitTime);
bool a=attachEvent0.WaitOne(waitTime);
...
}catch(Exception e)
{}
시큐우
시큐우2mo ago
i tried already but nothing was catched
Omnissiah
Omnissiah2mo ago
then i guess you sould look in event viewer to have details on the error
시큐우
시큐우2mo ago
Use the generic Events Viewer to diagnose your app - Visual Studio ...
Learn about the generic events viewer, which helps you better diagnose how your app is doing within the Visual Studio profiler.
Omnissiah
Omnissiah2mo ago
i mean eventvwr.msc, or "Event Viewer" if you search it in the system applications (which yes is related to that)
시큐우
시큐우2mo ago
ok i see :bap:
Omnissiah
Omnissiah2mo ago
if it's really an uncatchable exception the source then is outside the framework, and so it could potentially be a pretty difficult error to decipher
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Omnissiah
Omnissiah2mo ago
btw i don't if it's strecthed but it's a weird font there's some pretty weird kerning too
시큐우
시큐우2mo ago
i think there's nothing releated to this error,,?
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
시큐우
시큐우2mo ago
var mutex = new Mutex(false, "TestShareMutex", out bool createdNew);
var commEvent0 = new EventWaitHandle(false, EventResetMode.ManualReset, "TestEvent0");
var attachEvent = new EventWaitHandle(false, EventResetMode.ManualReset, "TestAttachEvent");
if (!createdNew)
{
mutex.WaitOne();
}
int waitTime = 9000000;

if (mutex.WaitOne(waitTime))
{
attachEvent.Set();
mutex.ReleaseMutex();
bool b = mutex.WaitOne(waitTime);
bool a = attachEvent0.WaitOne(waitTime);
System.Diagnostics.Debug.WriteLine(a.ToString());
Thread.Sleep(800);
if (a && b)
{
mutex.ReleaseMutex();
}
}
var mutex = new Mutex(false, "TestShareMutex", out bool createdNew);
var commEvent0 = new EventWaitHandle(false, EventResetMode.ManualReset, "TestEvent0");
var attachEvent = new EventWaitHandle(false, EventResetMode.ManualReset, "TestAttachEvent");
if (!createdNew)
{
mutex.WaitOne();
}
int waitTime = 9000000;

if (mutex.WaitOne(waitTime))
{
attachEvent.Set();
mutex.ReleaseMutex();
bool b = mutex.WaitOne(waitTime);
bool a = attachEvent0.WaitOne(waitTime);
System.Diagnostics.Debug.WriteLine(a.ToString());
Thread.Sleep(800);
if (a && b)
{
mutex.ReleaseMutex();
}
}
i've seen all the logs in the same timestamp when i runned the program, but doesnt seem to be there
Omnissiah
Omnissiah2mo ago
is there any log with this process name? anyway there is no attachEvent0 declaration there
시큐우
시큐우2mo ago
i could find the process name only for some previous runtime errors that i already solved and the attachEvent0 is same as attachEvent but just different name
Want results from more Discord servers?
Add your server