Solved

Asynchronous Functions

Posted on 1998-06-21
4
245 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
[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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
MFC Dialog 9 53
firstChar challenge 13 135
wordappend challenge 8 225
wordmultiple challenge 12 157
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…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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