Click here to Skip to main content
15,915,093 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to format a floppy disk? Pin
Shuang. Wu17-May-04 14:54
Shuang. Wu17-May-04 14:54 
GeneralCMD access Pin
contemptx16-May-04 22:57
contemptx16-May-04 22:57 
GeneralRe: CMD access Pin
Alexander M.,16-May-04 23:56
Alexander M.,16-May-04 23:56 
GeneralRe: CMD access Pin
David Crow17-May-04 2:40
David Crow17-May-04 2:40 
GeneralGetting the text of the MS Access SQL-View Edit Pin
steven1116-May-04 22:28
steven1116-May-04 22:28 
GeneralProblem with _beginthread Pin
Stephan Pilz16-May-04 21:57
Stephan Pilz16-May-04 21:57 
GeneralRe: Problem with _beginthread Pin
valikac17-May-04 6:54
valikac17-May-04 6:54 
GeneralRe: Problem with _beginthread Pin
Stephan Pilz17-May-04 20:06
Stephan Pilz17-May-04 20:06 
Good morning kuphryn,

there are more than one threadfuncs. All of this have the same prototyp:
void ThreadFuncName (void *args);

The application have one timer for each thread to start, but no thread should be run, if there an other running thread. To solve this, I use an self written thread-calling-queue. If a timer call, the corresponding thread would be add to my queue. The queue use a simple list and each element is a struct like this:

typedef void (*ThreadFunc) (void *args);<br />
<br />
typedef struct _THREADLIST_STRUCT {<br />
  ThreadFunc         ThreadFkt;	// Pointer to threadfunc<br />
  long               ThreadId;	// ID for internal use<br />
  _THREADLIST_STRUCT *next;     // Pointer to next element<br />
} THREADLIST_STRUCT;


And I have an other timer (1 second). He looks in me queue and is there a thread in and no other running thread, he starts the first element.

unsigned long t_id = 0;<br />
<br />
t_id = _beginthread (m_Root->ThreadFkt, 0, m_pParent);<br />
if (t_id != -1) {<br />
  // it's OK<br />
} else {<br />
  / do an error message<br />
}


Each access of the internal thread-list (AddThread, DelThread, StartThread, ...) is protected via a semaphore. Each thread remove himself from the queue at the end of thread and call _endthread().

As I already said, I works !!!, but after 10-100 thread-calls, it doesnt work again. The _beginthread () return a value != 0 and != -1 -> no error message. But the thread is'nt called. This effect exist only on one machine. The only one, there it should work in real life. This machine have:
- W2K with latest SP's and Updates
- complete installed Visual Studio .NET 2002 German (we have some problems with the compiler in the actual VS.NET !!)
- SQLServer ODBC driver
- pcAnywhere 10.5


Thanks
Stephan
GeneralRe: Problem with _beginthread Pin
valikac17-May-04 20:16
valikac17-May-04 20:16 
GeneralA question for C++ gurus about exception handling Pin
Daniel Strigl16-May-04 21:13
Daniel Strigl16-May-04 21:13 
GeneralRe: A question for C++ gurus about exception handling Pin
Prakash Nadar16-May-04 21:39
Prakash Nadar16-May-04 21:39 
GeneralRe: A question for C++ gurus about exception handling Pin
Curi0us_George16-May-04 21:46
Curi0us_George16-May-04 21:46 
Generalconst function Pin
Jerome Conus16-May-04 20:53
Jerome Conus16-May-04 20:53 
GeneralRe: const function Pin
nguyenvhn16-May-04 21:12
nguyenvhn16-May-04 21:12 
GeneralRe: const function Pin
Jerome Conus16-May-04 21:32
Jerome Conus16-May-04 21:32 
GeneralRe: const function Pin
Curi0us_George16-May-04 21:56
Curi0us_George16-May-04 21:56 
GeneralRe: const function Pin
Jerome Conus16-May-04 22:51
Jerome Conus16-May-04 22:51 
GeneralRe: const function Pin
Curi0us_George16-May-04 23:39
Curi0us_George16-May-04 23:39 
GeneralRe: const function Pin
nguyenvhn16-May-04 22:53
nguyenvhn16-May-04 22:53 
GeneralRe: const function Pin
Michael Dunn17-May-04 0:41
sitebuilderMichael Dunn17-May-04 0:41 
GeneralRe: const function Pin
Antony M Kancidrowski17-May-04 1:18
Antony M Kancidrowski17-May-04 1:18 
GeneralJPG Image In Picture Control Pin
balajeedurai16-May-04 19:56
balajeedurai16-May-04 19:56 
GeneralRe: JPG Image In Picture Control Pin
ThatsAlok3-May-05 23:20
ThatsAlok3-May-05 23:20 
GeneralProblem with CBitmapButton Pin
lostris16-May-04 19:52
lostris16-May-04 19:52 
GeneralRe: Problem with CBitmapButton Pin
David Crow17-May-04 2:45
David Crow17-May-04 2:45 

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.