Solved

Asynchronous Functions

Posted on 1998-06-21
4
216 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
Comment Utility
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
Comment Utility
Look for "CWinThread" and "Multithreading: Creating Worker Threads" on the help.
0
 
LVL 9

Accepted Solution

by:
Priyesh earned 200 total points
Comment Utility
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
Comment Utility
Thank U.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now