Oppinions - Is this the correct way to create, use and end a thread?

2203 byte By Alin at 2007-11-19 22:18:37
Please let me know what you guys think. I would be especially interested in your oppinions regarding the way the thread is ended is the destructor. Thanks a lot!.h:// tDlg.h : header file//#pragma once#include "afxwin.h"// CtDlg dialogclass CtDlg : public CDialog{// Constructionpublic: CtDlg(CWnd* p...

Fastest method for watchdog function?

1058 byte By typewriter at 2007-11-19 22:18:50
Hello Gurus, former lurker here.I have a GUI MFC program that is basically a webcam inferface. What I need to do, is add a function that will run concurrently with the main gui, calling a function to check external hardware as often as possible. It needs to be on the order of 1-5 ms frequency. It...

Threads in MFC - can you help a beginner?

1103 byte By Bulhakov at 2007-11-19 22:18:53
I created a simple MFC dialog application with an OpenGL display and a few standard slider controls to manipulate 3D objects. Now, I am working on adding sound synthesis to this project (I used the popular P.Cook's Synthesis Toolkit). However, when the sound generation loop runs (sending 44100...

Worker thread function call discrepancies

571 byte By typewriter at 2007-11-19 22:19:04
Is there any reason that a member function called from a worker thread function (via LPVOID pParam pointer) would behave differently than if the member function is called from somewhere else, like from another member function, or a MFC button click?The called member function in question doesnt do a...

Interview Questions ... Please Answer!

1601 byte By Aryan2k6 at 2007-11-19 22:25:08
Can someone please answer the below questions?Thanks in advance!=====1. How do you ensure data consistency with mulitple threads.2. How do you implement a single linked with multiple threads accessing and updating the same. What are the different ways to do it. What is best for performance?3. Write...

How to determine if CWinThread::InitInstance failed?

208 byte By Rigel at 2007-11-19 22:25:25
I have a GUI thread subclass of CWinThread. <br/>After I create the thread using AfxBeginThread I would like to know whether or not the overridden InitInstance function failed. How can I go about doing that?

PostMessage to parent thread

862 byte By DrPowers at 2007-11-19 22:30:04
I need to post a message to a threads parent thread so that it can be notified that a buffer can be read.this is what I have in the child thread: CString *s = new CString("asdsdf"); if(!PostMessage(HWND_BROADCAST, IPM_DRAWFRAME, 0, (LPARAM)s)){ theApp.Write("New...

Form freezed with multithread

796 byte By Laurent W at 2007-11-19 22:30:52
I have a single object winForm that include a tabControl.The tabs of the tabContol use a userControl I have made.My userControl is composed with a richeditBox, and 2 buttons.Each Tab of the TabControl are linked to a thread that display data.This WinForm is instancied by an application that manages...

Variable Passing problem in multithreading

587 byte By novice genius at 2007-11-19 22:33:27
Hi, I am trying to pass a variable to a thread as follows:void CDataExtractorDoc::StartWork(){ int sa = 5; CString temp;temp.Format("%d",sa); AfxMessageBox(temp); //PRINT1 AfxBeginThread(SinglePageThread,(LPVOID)&sa);}UINT CDataExtractorDoc::SinglePageThread(LPVOID pParam){...

Unresponsive GUI

682 byte By fuoco at 2007-11-19 22:34:02
I'm new to multithreading so here is the problem.I have an application whose GUI is unresponsive due to polling. Is it possible to using a workerthread to listen to user input? Can I even use a worker thread? What should the thread do in it's run funtion?Heres the code snippet in the main...

Threads in C++ (on unix)

273 byte By pcotton at 2007-11-19 22:36:17
Hi!<br/>We are trying to code a multi-threaded application in C++ using gcc on solaris unix box. <br/>Can anybody help me to understand how to make a member function of a class to be the thread function? Is this possible?<br/>Thanks in advance<br/>Priya

Do I need a MUTEX for... ?

579 byte By maprich at 2007-11-19 22:36:54
Hi,Do I need a mutex to read/write a single global variable :volatile int my_number;I understand quite well that if updating concurrently some struct type then the mutex would be necessary to prevent the situation where some thread would read some half-updated structure and get corrupted data as a r...

How to reduce CPU usage?

316 byte By ishtarsg at 2007-11-19 22:43:04
Hi allI had this problem that my software is using 100% of the CPU processing time.I am using multi threading in my software.does while loop actually eat up all processing power?and is there any way i can reduce the CPU power without affecting my software performance.Thanks in advance....

Multithreading taking more time ?

1787 byte By viks at 2007-11-19 22:45:02
Hi guysPlease dont make my fun,this is first time i am using threading in my code.From following code I am expecting to write current time using DateTime::Now (hh:mm::ss::ffffff)But my problem is that I am seeing around 20 ms difference between two write. Why ??Shouldn't it run continuesly wit...

std::string and multithreading

680 byte By markiemooster at 2007-11-19 22:45:31
I have a program that initialises an object CCamera in one thread and then passes a pointer to this object pCamera to several other threads.class CCamera{::public:const int GetPort() const { return m_nPort; };const char* GetName() const { return m_strName.c_str(); };:private:std::string m_strName;in...

Help Needed in Synchronizing Access to Neural Net

2102 byte By MikeAThon at 2007-11-19 22:47:05
I'm writing a backpropagation neural net which (to take advantage of dual core machines) should be trainable by multiple threads, and I need some advice on how to synchronize the threads' access to it. Visual Studio 6.0, WinXP.Basically, the weights in a neural net are trained in a two-st...

worker thread

860 byte By dave2k at 2007-11-19 22:49:16
i want to create a thread on click of button, trouble is i only want one thread and on multiple clicks loads are created.CLobby::CLobby(void){ m_pThread = 0; m_bRunning = false;}CLobby::~CLobby(void){}bool CLobby::Browse(void){ if(m_bRunning) return false; m_pThread = AfxBeginThread(ThreadFu...

FileMaker Pro problem

751 byte By Ken182 at 2007-11-19 22:49:42
We are and office running a FMP database on a internal server so (so obviously a LAN) it has been running sweet for about 4 years now. We have problems arising from the march of technology.We access the database through a web browser - IE 5.2.3 - since IE is no longer made for the Mac we have to re-...

my question about threading spawn

237 byte By Entrant_phil at 2007-11-19 22:49:51
hi guys:<br/> i've got a question with it that is if 'CreateThread' differ from 'AfxBeginThread'.oddly enough msdn dont mention this issue if for true what makes a distinction. thx.<br/>have a nice day

even-odd sort

4449 byte By GeoHoffman49431 at 2007-11-19 22:54:32
I have a question about a project for school. I am to implement the odd-even sort using semaphores. for a list of N numbers we can create n/2 threads. Here is the code I have so far. I cant figure out my error:Description of algorithma) Odd-Even Transposition Sort AlgorithmConsider the concurrent od...

server busy window

419 byte By marioana at 2007-11-19 22:58:28
Hello,I have an application with 2 threads, first thread is for the grafical interface, the second one is for calculation. If the calculation thread throws an exception it closes and then the garafical thread waits for the user to close the window. The problem is that after the t.join() statement is...

critical section question

998 byte By grahamr -work at 2007-11-19 23:05:03
Do Win32 API critical section objects (those created via CRITICAL_SECTION and passed to InitializeCriticalSection() calls) know about other CS objects? I feel not.I make this assumption because at one point in my program a lot of data is being written to and subsequently read from the buffer and th...

General info on threads

521 byte By messin18 at 2007-11-19 23:05:43
I'm creating and MFC application that also has a rendering window. I have the rendering window running on another thread useing the CreateThread function call.Now i need to start passing data between the two threads. Memory is cheap for me so i want to use a double buffer solution. Could so...

createprocess problem.

95 byte By InternationScape at 2007-11-19 23:08:17
my program wants to call another exe file, and makes it execute like click it in its directory.

Realtime display app

1043 byte By slippygod at 2007-11-19 23:09:15
I have a C++ console app that continuously reads data from the serial port in an infinite loop and displays it (a software oscilloscope basically). I'm trying to move it to Visual C++, which I am not familiar with. I made a Windows Forms Application in Visual Studio, and that was easy enough to...

How to access UI elements from a thread in MFC?

1216 byte By Salild at 2007-11-19 23:16:54
[Andreas]: This question was asked in regards to the following FAQ ( http://www.dev-archive.com/forum/showthread.php?threadid=312454):I tried to do the same with an SDI application.But nothing is happening.Please tell me where I am wrong. //CthreadTestView.cppvoid CthreadTestView::OnBnClickedButton1(...

SetTimer call in CWinThread

1172 byte By kumar_subrahmanya at 2007-11-19 23:24:11
Hi All,I am using SetTimer API to create timers in a UI Thread (CWinThread derived class)The code looks as follows ->m_timerId=::SetTimer(NULL,0,1000,NULL);where m_timerId is a member data variable.My Message map & onTimer looks as follows.BEGIN_MESSAGE_MAP(CMyThread, CWinThread) ON_THREAD_MESSAG...

what is wrong with this multi worker thread code?

2112 byte By Apal at 2007-11-19 23:27:11
Hi Guru,I wrote a multi worker threads application. Sometimes it works well. But sometime CString str1, or str2 , or str3 from worker thread 1 or worker thread 2 is empty. The data was there. but worker thread did not get it from source. What's wrong ?The following is my code:void GetData(CS...

In need for some advice

619 byte By Pravish at 2007-11-19 23:35:43
Hey ThereI m new to multithreading and looking for some advice. I m developing some appllication in MSVC++ and using Windows programming. I just read abt Pthreads. I hv got the concept but want to knowif it is useful in windows programming. I also want to know abt the settimer() use in multirhreadi...

how to use the function QueueUserWorkItem()

831 byte By rackeychen at 2007-11-19 23:36:32
I used the QueueUserWorkItem() function in my vb.net project. In my code, i open two child thread using QueueUserWorkItem(), but I found that always only one thread can be started. i was so puzzled . i hope u can give me some tips. thx. the following is my code: Private Sub InitializeBtn_Click(ByV...

Multithreading - work and ownership

1304 byte By sericson at 2007-11-19 23:37:50
This is a newbie multithreading question. I have some code below (this is not working code, just an example I wrote here to help explain my question). I have 2 threads. Thread A instantiates a class called WorkerClass. Thread B calls a compute intensive method on the WorkerClass. In this example, wh...

help me

190 byte By Rahul.Shendurnikar at 2007-11-19 23:41:07
Hello friends,<br/> can you please give me some link where i can find simple and more informative example of Threeading.<br/> I am new to this topic, <br/>plz help me <br/>thanks in advance

get Count of number of threads running

322 byte By prashas_d at 2007-11-19 23:43:13
Hiii AllI am new to Threads in C.In my program I am creating some threads by using thread_create function. In case If I want to know the count of number of threadsrunning at any time, Is there any way to get it?Please help me in solving this issue.Thanks in Advance.Prash....

SetCursor in new thread failed >.<

446 byte By victorleung at 2007-11-19 23:45:06
I am programming in VC++ 6.0 (Win32).I found that setting cursor to the HourGlass by using SetCursor(LoadCursor(NULL, IDC_WAIT));failed when it is called in a new thread (created by _beginthread())I have checked the returned HCURSOR value. The code above runs well as if in the main thread EXCEP...

Multithreading problem or ... ?

670 byte By sedaghat at 2007-11-19 23:45:19
Hi,I use winscard.dll to communicate with smart cards Reader through usb ports.I have 2 cards that should be programmed simultaneously.I use threads to do this work.I defined 2 threads,then assigned each of them to a different sub with no critical section.Each of subs individually needs to 20 second...

Creating & running a thread problem

2730 byte By oti at 2007-11-19 23:45:38
I have a simple SDI application that starts a thread from the menu. The thread sends a custom message to the view and the view should draw a line when it receives a message. Here are my problems:1. If I remove the call to WaitForSingleObject function after I create the thread, I get a Debug Assertio...

Multithreading and DirectX

982 byte By AndrejJst at 2007-11-19 23:47:28
Hello Im working on a DirectX application and have encountered a problem. The application as it is, runs in main thread. All DirectX related things are executed in this main thread. For loading purposes i have two other threads. In windowed mode everything runs ok. All threads wor fine. But in fulls...

A problem for Threading Programming

309 byte By sunny_sz at 2007-11-19 23:47:30
Hello everybody : I am doing one app for thread-programming , and I met one question on thread programming now , could anyone help to settel my case . details for my project , pls. look through the attached . Any ideas would be very appreciated . Thank you in advance !...

realtime threads not preempted??

1937 byte By GeMaWess at 2007-11-19 23:57:36
Hi! I have a strange problem with realtime priority class threads in windows XP. I have an application that need (almost) realtime handling of external events and thus have a couple of realtime threads waiting on UPD/IP sockets etc. But to my suprise the threads seems not to be preempteed.From the...

Pthreads and variables corruption

1595 byte By Zero_effect at 2007-11-19 23:58:06
I use a function(createThread) to create new threads. These threads are using a class called TestClass. The object of type TestClass is created before the thread because I want to pass some information to it from the current thread.(which is written to TestClass::account and TestClass::specid) The p...

Some Multithreadinig query

549 byte By ishtarsg at 2007-11-19 23:59:42
Hi allI was wondering if suspend thread actually suspend the thread in mid of a process or after the last instruction in the thread.ie process1;process2;process3;process4;process5;if the instruction is now at process3 and i call up the suspend thread, will it stop at process3 instantanously?, if so...

General Question

1020 byte By messin18 at 2007-11-20 0:01:53
I'm new to multithreading and have a few questions.I have two threads runningOne thread is the MFC classAnd in my MFC class i create another thread for a Render class.My MFC class has a pointer to the Render class so i can pass it information.A few questions...Lets say i have a function in the...

hmm.. one questions..

1314 byte By varun_j at 2007-11-20 0:15:06
There might be an easy solution to this:Suppose I have a class called "forks" as follows:class forks{ public static int count; public fork() // Constructor { count = 0; } // up() is called by a Thread to increase the count value public static synchronized void up...

thread question

417 byte By pouncer at 2007-11-20 0:15:12
this is a typical thread function which i wantDWORD WINAPI Get_Ticket_Profile_Feed(LPVOID param){ //do the necessary stuff.. blah blah.. //code.. blah blah // then at the end.. if (param = "T") { //do the T stuff } else if (param = "P") { //do the P stuff }}but im not sure how to create the thread...

Threads in Windows XP embedded

239 byte By zvivered at 2007-11-20 0:15:59
Can I set a priority from 0 to 255 to a thread in "WinXP embedded" like in Real time operating systems (e.g vxworks) ?<br/>In WinXP I can set 8 values: from "THREAD_PRIORITY_TIME_CRITICAL" to "THREAD_PRIORITY_IDLE". <br/>Thanks.

How many Threads can I have ?

1918 byte By varun_j at 2007-11-20 0:19:17
1)I have an application in java. What would limit the number of threads it can have?Suppose I have a client- server application. The server has one thread to service one client. If I have 100 clients, the server has 100 threads running, one for each client request. What if there are 10000 clients, t...

Compiler Flag Os

92 byte By lovish_dhawan at 2007-11-20 0:20:32
Hi All,<br/>Could anyone tell why Os compiler flag is chosen<br/>Thanks<br/>Lovish

Debugging multithreaded apps

417 byte By roadragedave at 2007-11-20 0:23:09
Hi, I am trying to get to the bottom of a bug in an app that uses thread pools, some thread is corrupting the heap somewhere and the program doesnt crash until another thread tries to access the memory, its very difficult to get to the bottom of.Does anyone know of any page limiting tool in Solaris...

Difference between JAVA & MFC

210 byte By Sree2006 at 2007-11-20 0:26:05
Hi Friends,<br/>Can any one help me to give 5 to 10 differences between JAVA & MFC. <br/>Like what is good in JAVA & not in MFC similarly what is good in MFC and not in JAVA.<br/>Thanks & regards,<br/>Sree

Increasing the stack size of a Thread

752 byte By prashas_d at 2007-11-20 0:27:54
Hii AlllI am new to Threads in C. I am doing C in Unix Solaris.In my program for creating Threads I am using the functionthr_create( NULL, 0, ThreadFunc, NULL, THR_BOUND, NULL ))in which second argument indicates the stack size. 3rd argument is function name in which Thread executes.If we give it as...