Click here to Skip to main content
15,914,014 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problems with the accessing the parallel port using winio Pin
Max Santos4-Oct-04 0:31
Max Santos4-Oct-04 0:31 
Generalauto hiding the parent Pin
Poorniselva4-Oct-04 0:11
Poorniselva4-Oct-04 0:11 
GeneralRe: auto hiding the parent Pin
Neville Franks4-Oct-04 0:14
Neville Franks4-Oct-04 0:14 
GeneralRe: auto hiding the parent Pin
Poorniselva4-Oct-04 20:42
Poorniselva4-Oct-04 20:42 
GeneralMulti-Threaded Application Pin
Sujan Christo3-Oct-04 23:51
Sujan Christo3-Oct-04 23:51 
GeneralRe: Multi-Threaded Application Pin
Neville Franks4-Oct-04 0:11
Neville Franks4-Oct-04 0:11 
GeneralRe: Multi-Threaded Application Pin
Sujan Christo4-Oct-04 0:29
Sujan Christo4-Oct-04 0:29 
GeneralRe: Multi-Threaded Application Pin
Sujan Christo4-Oct-04 1:01
Sujan Christo4-Oct-04 1:01 
Hi Franks,
I tried a dialog based program 4 multithreading. Here i am adding the sourcing which i have created.

#define MAX_CONNECTIONS 5
#include <afxmt.h>
static CWinThread *multthreads[MAX_CONNECTIONS];
static CEvent m_eventShutdown[MAX_CONNECTIONS];
static HANDLE hShutDown[MAX_CONNECTIONS];
static int shutdownWait[MAX_CONNECTIONS];
static int ShutThreadIndex;
int tableCount = 0;

//OnInitDialog
for (int count=0;count<max_connections;count++)
{
hshutdown[count]="NULL;
" shutdownwait[count]="0;
}
hShutDown[0]" =="" wait_object_0;

="" worker="" thread="" function
uint="" dataaccessthreading(lpvoid="" pparam)
{

="" dword="" dwret="WaitForMultipleObjects(MAX_CONNECTIONS,hShutDown,FALSE," infinite);

="" switch(dwret)
="" {
="" case="" wait_timeout:
="" break;
="" wait_failed:
="" while="" (true)
="" trace1("\ncaching="" 0x%x="" ",getcurrentthreadid());
="" switch(::waitforsingleobject(m_eventshutdown[shutthreadindex].m_hobject,shutdownwait[shutthreadindex]))
="" wait_object_0:
="" this="" is="" what="" we="" want="" to="" happen.
="" trace("wait_object_0");
="" break;

="" wait_timeout:="" something="" bad="" happened="" -="" force="" the="" termination
="" trace("timeout");
="" ::terminatethread(*i,="" 1);
="" wait_abandoned:="" has="" been="" terminated="" already!?="" maybe...
="" trace("wait_abandoned");
="" default:
="" trace("other");
="" }

="" sleep(2000);
="" trace("exit="" \n");
="" wait_object_0="" +="" 1:
="" trace("userobject="" trace("defalut="" }
=""
="" return="" 0;
}

="" start="" a="" i="" am="" using
void="" cmultitestingdlg::onbuttonstart()
{
="" multthreads[0]="AfxBeginThread(DataAccessThreading,p,0,0,CREATE_SUSPENDED);
" multthreads[0]-="">m_bAutoDelete = FALSE;
multthreads[0]->ResumeThread();
hShutDown[1] = multthreads[0]->m_hThread;
}

//To Shutdown the thread i am using
void CMultiTestingDlg::ShutdownThread(int i)
{
ShutThreadIndex = i;
shutdownWait[ShutThreadIndex] = INFINITE;
m_eventShutdown[ShutThreadIndex].SetEvent();
TRACE1("\nShutdown Index %d\n",i);
}
The problem i am facing is, when i give shutdownthread, sometimes it is closing the correct thread, sometimes it is not closing the correct thread.
PLEASE HELP ME. AM I GOING ON THE RIGHT DIRECTION.
SORRY FOR TROUBLING YOU MUCH.
THANX IN ADVANCE
Sujan
GeneralRe: Multi-Threaded Application Pin
Neville Franks4-Oct-04 2:40
Neville Franks4-Oct-04 2:40 
GeneralThanx a lot Franks Pin
Sujan Christo4-Oct-04 18:27
Sujan Christo4-Oct-04 18:27 
GeneralRe: Multi-Threaded Application Pin
Sujan Christo5-Oct-04 0:10
Sujan Christo5-Oct-04 0:10 
GeneralRe: Multi-Threaded Application Pin
Bob Stanneveld4-Oct-04 4:25
Bob Stanneveld4-Oct-04 4:25 
GeneralRe: Multi-Threaded Application Pin
Sujan Christo4-Oct-04 21:36
Sujan Christo4-Oct-04 21:36 
GeneralRe: Multi-Threaded Application Pin
valikac4-Oct-04 6:29
valikac4-Oct-04 6:29 
GeneralChanging color of the Edit box Pin
Neelesh K J Jain3-Oct-04 23:25
Neelesh K J Jain3-Oct-04 23:25 
Generalstopwatch, timer.... Pin
marcomars3-Oct-04 23:16
marcomars3-Oct-04 23:16 
GeneralRe: stopwatch, timer.... Pin
Neville Franks4-Oct-04 0:24
Neville Franks4-Oct-04 0:24 
GeneralRe: stopwatch, timer.... Pin
David Crow4-Oct-04 4:09
David Crow4-Oct-04 4:09 
GeneralBYTE array and lists Pin
mcsherry3-Oct-04 23:01
mcsherry3-Oct-04 23:01 
GeneralRe: BYTE array and lists Pin
Antony M Kancidrowski4-Oct-04 0:37
Antony M Kancidrowski4-Oct-04 0:37 
GeneralRe: BYTE array and lists Pin
mcsherry4-Oct-04 2:32
mcsherry4-Oct-04 2:32 
GeneralRe: BYTE array and lists Pin
Antony M Kancidrowski4-Oct-04 3:52
Antony M Kancidrowski4-Oct-04 3:52 
GeneralRe: BYTE array and lists Pin
mcsherry4-Oct-04 4:30
mcsherry4-Oct-04 4:30 
GeneralRe: BYTE array and lists Pin
Robert A. T. Káldy4-Oct-04 7:11
Robert A. T. Káldy4-Oct-04 7:11 
QuestionHow can I interface PCB Borad and VC++ Program (Embedding ) Pin
Benedict Alphonse3-Oct-04 22:04
Benedict Alphonse3-Oct-04 22:04 

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.