Solved

Asynchronous Functions

Posted on 1998-06-21
4
240 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 145
Process filename extension 3 194
fizzArray2 challenge 1 89
How do I get Window Title of all opened process? 4 11
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seveā€¦
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

809 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