Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to implement Multi-threading

Posted on 1998-01-11
1
389 Views
Last Modified: 2008-03-03
I am building an SDI MFC application which has a user interface class and a database class.  I am also using a virtual device driver to access the network interface card in a promiscuous mode.  The packet monitor function makes a call to DeviceIoControl to retrieve any packets that arrive at the NIC.  Since at any moment, there may or may not be a packet to read, I call GetOverlappedResult which waits indefinetly for a packet arrival.  This, of course locks up the many windows GUI messages I am using to update the GUI, since windows is in a single thread mode and I am blocking any other progress.  How should I implement this function to run under a separate thread and still have the packet results available to the other thread?

Thanks
0
Comment
Question by:bknouse
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1178138
You need to create a function that matches this prototype:

  LRESULT MyThreadedFunc(LPVOID param);

Then you can use AfxBeginThread(MyThreadedFunc, anyParam);

You also need to structure your code so that it is doing something like

  {
    while (TRUE)
    {
      GetOverlappedResult(...);
      /* communicated with program that result is ready */
    }
  }


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

839 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