Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Asynchronous Functions

Posted on 1998-06-21
4
Medium Priority
?
265 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 800 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 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