Simple question about running threads

Posted on 2006-04-29
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;
     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.

Question by:cheapstr
    LVL 43

    Accepted Solution

    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)

    Author Comment

    That's what I was wondering. Thanks.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    WinWaitActive parameters 12 30
    Prevent this page from creating additional dialogs. 3 167
    Line meaning 9 57
    mapAB Challlenge 35 55
    Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
    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…
    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.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now