Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Problem breaking loop (with close button) in main thread
Re: Problem breaking loop (with close button) in main thread [message #59041 is a reply to message #59040] Wed, 19 October 2022 02:42 Go to previous messageGo to previous message
Lance is currently offline  Lance
Messages: 527
Registered: March 2007
Contributor
In the loop (by goto, there is an implicit loop), if you call ProcessEvent, which gives chance for Paint() who will call this function one more time and stuck in the same [b]WaitForSingleEvent[b] failure, and it will call [b]ProcessEvents[b] in its waiting loop, ... it goes on until stack is exhausted. I might be wrong, but that's my gut's feeling why adding ProcessEvent doesn't work for you.

I would add some check like this:

DWORD GuiAcquireMutex(HANDLE hMutex, DWORD dwTimeout)
{
  static int inthecall;

  if( inthecall )
       return ERROR_IN_CALL; // define this value yourself
  ++inthecall;
  if(hMutex == INVALID_HANDLE_VALUE)
   return ERROR_INVALID_HANDLE;
 
 long long llNow;
 long long llStart        = GetMilliTime();
 long long llEnd          = llStart + (long long) dwTimeout;
 DWORD     dwShortTimeout = 1000;        // 1 second
 DWORD     dwLastError;
 DWORD     dwWaitResult;
   ....

Make sure you --inthecall; in all branches before leaving the function.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Dealing with background tasks elegantly in a userinterface
Next Topic: error / memory leak in HttpServer example
Goto Forum:
  


Current Time: Fri May 17 20:58:43 CEST 2024

Total time taken to generate the page: 0.02468 seconds