|
Well, given that I've understood your problem correctly I suggest the following:
1. Set up interface sinks and create objects necessary.
2. Create a worker thread that gathers the data from the demodulator and put the data in a queue which is read from...
3. a second worker thread that feeds the sound card and waits for an event which gets signalled when your app is notified using WFMO().
4. Marshal needed interfaces to your threads before you unleash them. (Create them suspended.)
This will keep the GUI responsive since the main thread is not blocked.
You should also get the notification in the main thread.
Read JoeNewcomer's article[^] about multithreading if you are unfamiliar with the subject.
Hope this helps
--
Roger
It's suppose to be hard, otherwise anybody could do it!
|
|
|
|
|
(VS 2005 MFC) I have a list of 5 threads, for example:
struct T_PARAMS
{
HWND hWnd; // a handle to dialog window, using in thread
};
int thread_count = 5; // I have 5 threads
CWinThread *pThread; // pointer to thread
CList<cwinthread*, cwinthread*=""> mList; // list of the pointers to threads
int lp = 0;
// First I create 5 stopped threads:
for(lp = 0; lp < thread_count; lp++)
{
params = new T_PARAMS();
params->hWnd = m_hWnd;
pThread = AfxBeginThread(ThreadFunc, params, THREAD_PRIORITY_NORMAL, 0,
CREATE_SUSPENDED);
pThread->m_bAutoDelete = true;
mList.AddTail(pThread);
}
Now, when I have a list of pointers to threads, I want run threads, but I want to do it in this way: run first thread (mList[0]), wait so long how the first thread is working, next run second thread (mList[1]) and so on. For example:
POSITION pos;
CWinThread *wsk = NULL;
pos = mList.GetHeadPosition();
for(lp = 0; lp < thread_count; lp++)
{
wsk = (CWinThread *) mList.GetNext(pos);
wsk->ResumeThread();
// [*] now wait until thread is working - how to do it?
}
My threads are working properly, I use one semaphor to allow works only 1 thread at once, but I don't know how can I do - in line [*], that programm will wait after wsk->ResumeThread() until this thread is finished his work?
Regards
mwgomez
Poland
|
|
|
|
|
Have a look at Joe Newcomer's article about worker threads. It's excellent!
He'll show you how to all of this the correct way here[^].
I urge you to read the complete article since it will make you aware of problems you have to know how to deal with when doing multithreading.
Hope this helps
--
Roger
It's suppose to be hard, otherwise anybody could do it!
|
|
|
|
|
First when you create the thread but before you let it run make sure you do the following (you will have to create it suspended):
pThread->m_bAutoDelete = FALSE;
There is no point in having a collection of CWinThread pointers if you have no way of knowing if the object pointed to has been delete or not!
Now you can wait for a thread to exit using the Win32 API as follows:
WaitForSingleObject(pThread->m_hThread, INFINITE);
Remember we've turned auto deletion off so you have to remember to delete the CWinThread objects when you're done with them - deleting one doesn't stop the thread running (if it's running).
Steve
|
|
|
|
|
how to write a logfile in the COM component
suresh
|
|
|
|
|
Use an ofstream object for that:
ofstream OutputFile("MyFile.txt");
int SomeVariable = 10;
OutputFile<<"SomeText"<<SomeVariable<<endl;
|
|
|
|
|
ok thanq
but,i want create .txt file at the server side.........
suresh
|
|
|
|
|
Which server ?? Please when asking a question be more specific. What are you trying to do exaclty ? Provide as much relevant information as possible.
|
|
|
|
|
Then give a file name to a file at the server! Example:
\\Server02\Share$\aDirectory\aTextFile.txt
|
|
|
|
|
Is there a way to do this in Windows without .neT?
Thanks!
|
|
|
|
|
BOOL CreateDirectory(
LPCTSTR lpPathName, // pointer to directory path string
LPSECURITY_ATTRIBUTES lpSecurityAttributes // pointer to security descriptor
);
BOOL RemoveDirectory(
LPCTSTR lpPathName // pointer to directory to remove
);
|
|
|
|
|
|
hi,
i have 2 variables like
char * username
char sysname[MAX_PATH]
i need to use "NetUserGetInfo" windows API method, which takes two LPCWSTR strings, how can i convert the above sysname,username to pass them to NetUserGetInfo.
thanks
|
|
|
|
|
Use A2W string conversion macro.
void func( LPSTR lpsz )
{
USES_CONVERSION;
...
LPWSTR x = A2W(lpsz)
...
}
Nibu thomas
Software Developer
|
|
|
|
|
I need exactly the reverse way,
that is i have char* username, char sysname[max_PATH].
i need to pass these 2 variables to NetUserGetInfo(LPCWSTR,LPCWSTR)
thanks
|
|
|
|
|
gbabu17 wrote: I need exactly the reverse way,
that is i have char* username, char sysname[max_PATH].
i need to pass these 2 variables to NetUserGetInfo(LPCWSTR,LPCWSTR)
Nibu thomas
Software Developer
|
|
|
|
|
Life isn't easy, isn't ?
|
|
|
|
|
if your problem is NetUserGetInfo for conversition) use (or like this)
LPTSTR user;
LPTSTR computer;
user=(LPTSTR)LocalAlloc(LPTR,256);
computer=(LPTSTR)LocalAlloc(LPTR,256);
DWORD d=256;
GetUserName(user,&d);
DWORD dd=256;
GetComputerName(computer,&dd);
wchar_t *m_User = T2W(user);
wchar_t *m_computer = T2W(computer);
DWORD dwLevel = 4;
USER_INFO_2 *m_Userinfo;
DWORD dddd=NetUserGetInfo(m_computer, m_User , 2, (LPBYTE*)&m_Userinfo);
|
|
|
|
|
Which is what A2W() does. I've done it this way in the past:
LPUSER_INFO_2 pUserInfo = NULL;
CString strUser;
NET_API_STATUS nStatus = NetUserGetInfo(L"\\\\server", A2W(strUser), 2, (LPBYTE *) &pUserInfo);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
I have faced this question in an interview,
Design algorithm for elevators using any design pattern.
please guide me regarding this.
krishna
|
|
|
|
|
Well I can give a brief description
When they go up they keep going up processing the requests on the way.
and
When they come down they keep coming down processing the requests on the way.
They don't change direction in between unless they have processed all requests in that direction
and
BTW if anybody gives another request before it changes direction it processes that too.
This is called the elevator algorithm.
Nibu thomas
Software Developer
|
|
|
|
|
hai,
can u elaborate this , just like what r the abstract base class we r designing for this and derived classes and some importnt methods.
|
|
|
|
|
Composite Pattern - For the structure, components and movement of the elevator (e.g. doors, switches, lightsource etc.).
Iterator Pattern - For the list of floors.
Observer Pattern - To identify on which floor to stop.
Rahim Rattani
Software Engineer,
Matrix Systems (Pvt) Ltd.,
Karachi - Pakistan
|
|
|
|
|
Hi there!
I'm writing a server, which shold have an update function. So it should replace it's own executable file with a new version. Has any one an idea how to manage that?
Thank you!
|
|
|
|
|
if MyServer.exe is currently running, it won't be able to overwrite its own exe
What you'll need to do is something like this
in MyServer.exe
Check internet for update
if update available
{
download update package
launch Updater.exe
quit MyServer.exe (saving everything gracefully)
}
---
in Updater.exe
Wait for MyServer.exe to shut down
Depack update package
Launch updated Myserver.exe
quit Updater.exe
---
You might want to set this update process so that it can be scheduled at a quiet time for your server. E.g. if it's main traffic is from 9am - 5pm, then make it try to update at 5am
--
Help me! I'm turning into a grapefruit!
Buzzwords!
|
|
|
|