Click here to Skip to main content
15,919,358 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Cannot Run the Database on other PC Pin
Steve S22-Feb-04 22:29
Steve S22-Feb-04 22:29 
GeneralRe: Cannot Run the Database on other PC Pin
Tim Smith21-Feb-04 17:15
Tim Smith21-Feb-04 17:15 
GeneralRe: Cannot Run the Database on other PC Pin
David Crow23-Feb-04 3:24
David Crow23-Feb-04 3:24 
GeneralRe: Cannot Run the Database on other PC Pin
siew hoon27-Feb-04 16:31
siew hoon27-Feb-04 16:31 
GeneralRe: Cannot Run the Database on other PC Pin
David Crow1-Mar-04 2:26
David Crow1-Mar-04 2:26 
GeneralRe: Cannot Run the Database on other PC Pin
siew hoon1-Mar-04 4:06
siew hoon1-Mar-04 4:06 
GeneralMicrosoft Office Chart 9.0 Pin
krugger21-Feb-04 13:11
krugger21-Feb-04 13:11 
GeneralEnumWindows() Pin
Nirav Doshi21-Feb-04 12:17
Nirav Doshi21-Feb-04 12:17 
GeneralRe: EnumWindows() Pin
Gary R. Wheeler21-Feb-04 12:36
Gary R. Wheeler21-Feb-04 12:36 
GeneralRe: EnumWindows() Pin
Nirav Doshi21-Feb-04 12:41
Nirav Doshi21-Feb-04 12:41 
Generalconsole i/o problems Pin
#937021-Feb-04 12:04
#937021-Feb-04 12:04 
GeneralRe: console i/o problems Pin
valikac21-Feb-04 14:36
valikac21-Feb-04 14:36 
GeneralRe: console i/o problems Pin
#937022-Feb-04 1:56
#937022-Feb-04 1:56 
GeneralSomeone, Anyone Help Plz Pin
MrNiceBerG21-Feb-04 11:34
MrNiceBerG21-Feb-04 11:34 
GeneralRe: Someone, Anyone Help Plz Pin
Gary R. Wheeler21-Feb-04 12:09
Gary R. Wheeler21-Feb-04 12:09 
GeneralRe: Someone, Anyone Help Plz Pin
Ravi Bhavnani21-Feb-04 12:32
professionalRavi Bhavnani21-Feb-04 12:32 
GeneralRe: Someone, Anyone Help Plz Pin
Gary R. Wheeler21-Feb-04 13:05
Gary R. Wheeler21-Feb-04 13:05 
GeneralNeed help with restaring a thread Pin
Aralguppe21-Feb-04 8:23
Aralguppe21-Feb-04 8:23 
GeneralRe: Need help with restaring a thread Pin
Neville Franks21-Feb-04 9:50
Neville Franks21-Feb-04 9:50 
GeneralRe: Need help with restaring a thread Pin
Tim Smith21-Feb-04 12:10
Tim Smith21-Feb-04 12:10 
GeneralRe: Need help with restaring a thread Pin
Neville Franks21-Feb-04 20:01
Neville Franks21-Feb-04 20:01 
GeneralRe: Need help with restaring a thread Pin
Aralguppe22-Feb-04 7:09
Aralguppe22-Feb-04 7:09 
GeneralRe: Need help with restaring a thread Pin
Neville Franks22-Feb-04 9:24
Neville Franks22-Feb-04 9:24 
GeneralRe: Need help with restaring a thread Pin
Gary R. Wheeler21-Feb-04 12:21
Gary R. Wheeler21-Feb-04 12:21 
Like Neville said, the key is to ensure that your thread never exits in the first place. One simple way to do that is to encapsulate the body of the thread in a try/catch block:
UINT ThreadFunction(LPVOID parameter)
{
    for ( ; ; ) {
        try {
            // here's the code that can cause an exit
        }
        catch (...) {
            // here's where you handle failures
        }
    }
    return 0;
}
The catch (...) block catches all exceptions. Putting the try/catch block inside the for( ; ; ) loop creates the 'automatic restart' effect you are looking for.

Note that the catch (...) is typically considered to be poor practice. Too many programmers use it rather than catching the exact exceptions that they are interested in, which means error handling stops at that spot. In your case it would be a valid usage, since the catch (...) occurs at the outer edge of the executable code for the thread.


Software Zen: delete this;
GeneralRe: Need help with restaring a thread Pin
Aralguppe22-Feb-04 6:40
Aralguppe22-Feb-04 6:40 

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.