|
hi,
I heard we can do that using regions and tried a sample in SDI...its coming but not exactly like media player...so i will let u know once its completly coming
|
|
|
|
|
Hi All,
I am working on a multi-threaded appln.In that I want to create an array of worker threads (like CWinThread *multthreads[maxsize]), which manipulates on some data until i ask them to stop(Using waitForSingle/MultipleObject) PEACEFULLY(not terminating). Say if i may want to stop the thread @ the 5th position.
I am awaiting for your comments
Thanx in advance
SUjan
|
|
|
|
|
|
Hi Franks,
Thanx 4 the link. I'll look into it.
|
|
|
|
|
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
|
|
|
|
|
All thread functions DataAccessThreading() are accessing the same global data and they don't know which instance of the thread they are. So the first thread to check eventShutdown[ShutThreadIndex] which see it and behave as requested.
I would wrap:
static CWinThread *multthreads[MAX_CONNECTIONS];
static CEvent m_eventShutdown[MAX_CONNECTIONS];
static HANDLE hShutDown[MAX_CONNECTIONS];
static int shutdownWait[MAX_CONNECTIONS];
static int ShutThreadIndex;
in a class and create an array of these. The pass the array instance address into the DataAccessThreading() function. Each thread knows which intance it is and only needs to check its specific eventShutdown.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Dear Franks,
THANX A LOT.
I was literally struggling with this. I'll try as per your suggestion. Incase of need i'll trouble(SORRY 4 that) again.
Moreover i was having a doubt that whether i am going in the right direction.So your reply helps me a lot.
THANX A LOT
Yours
Sujan
|
|
|
|
|
Dear Franks,
I tried by creating a class and used it as you have said, still getting the same problem. Do you have any sample code, which does this. If you do have, will you please post it. I am in deep trouble.
SORRY FOR DISTURBING YOU AGAIN.
if the code is too large you can send it to my mail id also
AWAITING YOUR REPLY
Yours
Sujan
|
|
|
|
|
Hello,
I started a multithreaded application a few weeks ago and I find this[^] class extremely usefull.
Your code would look like this:
<br />
CThread threads[maxsize];<br />
threads[4].Stop();
Hope this helps..
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Hi Bob,
Just now only i saw your reply. Thanx, i'll go through the article.
Sujan
|
|
|
|
|
What data and how are the threads processing the data?
Kuphryn
|
|
|
|
|
Hello Friends,
I want to change the back ground color of the edit box at the time of initialization only. Even though i had used SetBkColor() and the SetBkMode() I couldn't able to change the color of the edit box.
Please help.
Thank you,
Neelesh J Jain.
|
|
|
|
|
Hello,
my mfc application is performing a time consuming operation.
Before this I want to prompt the user with an approximate estimate of the execution time.
For this my idea was to execute some (eg 100) cycles, get the elapsed time
and multiply this for the number of total needed executions.
In MATLAB (for MATLAB users) it would be a simple tic - toc command.
Is there something similar for VC++?
Or do you have an idea for another approach?
Thanks,
Marco.
|
|
|
|
|
|
marcomars wrote:
my mfc application is performing a time consuming operation.
Estimations aside, can you put this time-consuming operation in a separate thread? That way, no matter how long it takes or how off your estimations are, your main UI thread is not being blocked and remains responsive.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
My program needs to take a pointer to BYTE array (unsigned char*) and convert it into a STL list so that each BYTE in the array has its own element in the list, i.e. if the array has hundred bytes then the list needs to have a hundred entries, at present when I try to do this each element in my list points to the entire BYTE array, when what I really need is copies of each single BYTE in its own part of the list.
Does anyone know how I can do this?
cheers,
Andy
|
|
|
|
|
You could have something like
std::list<char> m_STLList;
for (int nByteCount = 0; nByteCount < entries_in_array; nByteCount++)
{
char* pByte = (pByteArray + nByteCount);
m_STLList.push_back(*pByte);
}
Hope this helps
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
cheers Ant for your reply. Unfortunatly when I use:
char* pByte = (pByteArray + nByteCount);
all I get is pByte pointing to the actual data in memory instead of making a copy of that particular byte.
Andy,
|
|
|
|
|
It is the line that adds it to the list that makes the copy (notice the *pByte)
m_STLList.push_back(*pByte);
if you like it can be changed to
char Byte = *(pByteArray + nByteCount);
m_STLList.push_back(Byte);
or
char Byte = pByteArray[nByteCount];
m_STLList.push_back(Byte);
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hi Ant,
I see what you mean now (I'm being a bit dense today! )
|
|
|
|
|
Code short and fast:
BYTE* byte_array;<br />
std::list<char> char_list;<br />
char_list.assign(byte_array, byte_array + number_of_entries_in_byte_array);
Robert-Antonio
"A flower walked around a meadow. She saw a beautiful human
and plucked off his head."
|
|
|
|
|
Hello friendz,
I am new member of this site.
i wish to develop new embedding project in VC++.
i want clear idea about How can i do it?.
Like Switch on lights using VC++ Program.
Please Give ideas...........
Thanking you.
Benedict
|
|
|
|
|
for this first you have to made electronic circutt that work on databit send vc++ applications.
because using software you can only give command rest of thing must be handle by machine or circutt.
then go for it???
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hai...
i am doing my project in vc++.
I have echo problem and noise problem in my voice chat.I am recording the sound using WaveIn devices
only and play back using Waveout devices.
I record the sound and compress it using ADPCM compression and send it.But i have some echo problem
and noise problem. I tried out some of the functions in Waveform but i can reduce it.
Can some one help me to reduce the problem
or give suggestion regarding this.
Can any one point out the reason for this problem.
This chat works very well in LAN but when we go for Internet all these occurs..
Kindly help me.
Thank u In advance.
M.Kailasam
|
|
|
|
|
Any tool used for memory leak detection works slowly with bitmaps since bitmaps require a lot of memory allocation and deallocation. I use BoundsChecker from Compuware. Can someone suggest a faster tool which scans memory faster? Thanks in advance.
Dipeka.A.J
|
|
|
|