?
Solved

How to implement Multi-threading

Posted on 1998-01-11
1
Medium Priority
?
417 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
[X]
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
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 300 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.
Suggested Courses

771 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