Click here to Skip to main content
15,920,628 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Modifying MFC Pin
jc0dex16-May-05 11:44
jc0dex16-May-05 11:44 
Generalusing a control from a .dll Pin
alex__b15-May-05 5:38
professionalalex__b15-May-05 5:38 
GeneralChanging the root in CFileDialog Pin
g_sol_115-May-05 3:48
g_sol_115-May-05 3:48 
GeneralRe: Changing the root in CFileDialog Pin
PJ Arends15-May-05 10:35
professionalPJ Arends15-May-05 10:35 
GeneralRe: Changing the root in CFileDialog Pin
g_sol_116-May-05 2:00
g_sol_116-May-05 2:00 
GeneralRe: Changing the root in CFileDialog Pin
PJ Arends16-May-05 7:23
professionalPJ Arends16-May-05 7:23 
GeneralThreads using up too much CPU Pin
15-May-05 3:47
suss15-May-05 3:47 
GeneralRe: Threads using up too much CPU Pin
the one dono15-May-05 6:20
the one dono15-May-05 6:20 
I've discovered that these threads aren't my problem.

I have one other thread that detects whether a server is either up or down.

I've found a solution for the problem, but I would like some experts to make some suggestions because I know that there must be a better way. There must be a built in Win32 function to solve my problem properly.

This is my problem thread...


int i = 0;
bool bSpxServerStatus = FALSE;
while(app_running)
{
        bSpxServerStatus = Check_That_Server_Is_Up();
        if(!bSpxServerStatus)
        {
                Reconnect();
        }


        /* My HACKED solution */
        for(i = 0; i < 55; i++) //The combination of a for loop, Sleep and SwitchToThread solves my problem.
        {
                SwitchToThread(); //Plain SwitchToThread Doesn't Work
                Sleep(55); //Plain Sleep(3000) didn't work either.
        }


}


With out my hacked solution my thread hogs all the CPU time. Is there a better way?
I don't need the thread to loop every second. Sleep(3000) doesn't work, and I've read you should never use it. http://www.flounder.com/badprogram.htm#Sleep[^]

Thanks in advance.
QuestionQuestion: How to retrieve the HINSTANCE when you have HWND? Pin
lxcid14-May-05 23:50
lxcid14-May-05 23:50 
AnswerRe: Question: How to retrieve the HINSTANCE when you have HWND? Pin
bharadwajgangadhar15-May-05 2:05
bharadwajgangadhar15-May-05 2:05 
AnswerRe: Question: How to retrieve the HINSTANCE when you have HWND? Pin
PJ Arends15-May-05 10:42
professionalPJ Arends15-May-05 10:42 
GeneralVisual C++ Callbacks Issue - Auto Callbacks Pin
Axonn Echysttas14-May-05 23:08
Axonn Echysttas14-May-05 23:08 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
the one dono15-May-05 4:47
the one dono15-May-05 4:47 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
Axonn Echysttas15-May-05 5:47
Axonn Echysttas15-May-05 5:47 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
the one dono15-May-05 6:34
the one dono15-May-05 6:34 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
Axonn Echysttas15-May-05 11:59
Axonn Echysttas15-May-05 11:59 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
ThatsAlok15-May-05 18:27
ThatsAlok15-May-05 18:27 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
Axonn Echysttas16-May-05 2:08
Axonn Echysttas16-May-05 2:08 
QuestionGetting WM_DROPFILES from child control? Pin
matthew18014-May-05 19:26
matthew18014-May-05 19:26 
GeneralAddFontResource Pin
Inov14-May-05 16:52
Inov14-May-05 16:52 
GeneralRe: AddFontResource Pin
Jack Puppy14-May-05 17:38
Jack Puppy14-May-05 17:38 
Generaldialog box Pin
rain71114-May-05 14:57
rain71114-May-05 14:57 
GeneralRe: dialog box Pin
David Crow15-May-05 16:28
David Crow15-May-05 16:28 
GeneralRe: dialog box Pin
rain71122-May-05 3:47
rain71122-May-05 3:47 
GeneralRe: dialog box Pin
David Crow23-May-05 1:56
David Crow23-May-05 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.