?
Solved

Simple question about running threads

Posted on 2006-04-29
2
Medium Priority
?
239 Views
Last Modified: 2013-11-20
I am pretty new at trying to use threads, but for someone with a little more experience this should be a very easy question to answer. In my application I have a method that runs a pretty intensive process. It is a pretty long method and has already been written. Now, if I start a new thread and in that thread I call this method, is this method running in a seperate thread or is it still being run by my application? Example:

void CTestDlg::Run()
{
  // A lot of processing here.
}

UINT CTestDlg::MyThread(LPVOID pParam)
{
     CTest* pView = (CTest*)pParam;
     pView->Run();
     return 0;
}

I am wondering because doing it this way my application window is pretty slow responding during the processing. I thought that running something as a seperate thread runs the function in the background and woudnt affect my application much, but I'm not sure if Run() is running as a seperate thread or if MyThread() is just calling Run() and my application is still doing all of that processing. Can anyone answer this for me? Thanks.

0
Comment
Question by:cheapstr
2 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 400 total points
ID: 16571542
What you have done is to create a separate thread that then instructs the MAIN thread to do the work in 'Run'.  That is why it is sluggish.
You need to do the work in the thread (MyThread)
0
 

Author Comment

by:cheapstr
ID: 16574104
That's what I was wondering. Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question