Solved

Asynchronous Functions

Posted on 1998-06-21
4
237 Views
Last Modified: 2013-11-20
My current project involves implementing imaging functionality inside a .dll.  I have used TWAIN for the imaging and gotten pretty used to it.  However, the project also requires that functions be done asynchronously (ie. done in the background).  TWAIN requires a message hook but since this is a dll module, the program 'steals' the app's message queue blocking all messages until the scan is finished.

Are there any other possible approaches here?  (Others suggested that I create a separate .exe that is launched by the .dll, but I think that is way too complicated, for me, at least).
0
Comment
Question by:ealva
4 Comments
 
LVL 2

Expert Comment

by:Belgarat
ID: 1318272
Can you run the scanning process in a separate thread ? In Win32 each thread has its own message queue, so the rest of your app should remain responsive to the user and TWAIN will block only that one queue.
0
 
LVL 5

Expert Comment

by:yonat
ID: 1318273
Look for "CWinThread" and "Multithreading: Creating Worker Threads" on the help.
0
 
LVL 9

Accepted Solution

by:
Priyesh earned 200 total points
ID: 1318274
Ealva, Please see threads.. they can work in the background without blocking any code of u'rs. If u have to do some message sending to the functions u plan to move to background, u have to go for a user interface thread. These threads have separate mesage queues and can handle messages. If u'r background function just does some lengthy calculation, u are fine with a woker thread. Please see AfxBeginThread, CreateThread etc.
U just have to declare a function like UINT ThreadFunc(LPVOID) ; U can pass anything casted to a void* into the thread. If u have to terminate the thread at some point from u'r main function, see CreateEvent and SetEvent, ResetEvent, and WaitForSingleObject. Please ask me if u can't find some sample code for all these....
  You are a perfect client for threads i think... good luck.. my email id is pgp@mailcity.com.
0
 

Author Comment

by:ealva
ID: 1318275
Thank U.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get filename and folder into excel 7 76
deburging in oracle form 12 99
Shell script to login to remote m/c and execute commands 10 78
while loop over for loop 7 105
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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