Solved

Multi-tasking using forms

Posted on 2000-04-28
5
148 Views
Last Modified: 2012-05-04
Ok, my problem is that my application has a function key which (should) go off to produce a report in the background.  This report isn't to be printed but,when ready, is displayed on a spreadsheet control.  In the meantime I would like the user to be able to carry on doing data-entry.

I've followed the coffee example in the VB documentation and also a couple of examples on this excellant website.  However they all seem to depend on use of the timer control.  When I ignore this and play around with the code to produce the report in the Active X exe my calling application still hangs whilst waiting for the exe to finish processing.

I can't set the ActiveX exe to run as unattended execution because it displays a form on completion of processing.  

What I would like is the processing to carry on in the background and an event raised to signal that the report is ready to be displayed.  How can I get this to happen?  

My ActiveX exe is set up as Multiuse and the projecties are set to 'thread per object'.  

Can anybody help?
0
Comment
Question by:saffron
5 Comments
 
LVL 18

Accepted Solution

by:
mdougan earned 500 total points
ID: 2759075
A simple answer would be for your Active-X exe to set a Public member variable to a specific value when complete.  

Your client application will call a public Sub in the Active-X exe.  All this sub will do is enable a timer in the Active-X exe, then the sub finishes and control is returned to your client app.  When the timer fires a second or so later in the Active-X exe it sets it's own enabled property to false and  starts to process your report, when finished it sets some global flag to True.

The client, meanwhile, after calling the public Sub in the Active-X exe to start the report, then it enables it's own timer.  This timer goes off every few seconds and checks the global flag in the Active-X EXE.  When it sees the value is True, it then calls the method in the Active-X EXE to display the report.

A more complicated answer is that you can use Multi-threading in your client application (no need for an active-x).  However, there are a lot of restrictions to using the CreateThread API under VB6 (VB5 has a little better support for multi-threading.  In Multi-threading, you can specify a Call-Back routine, so that when the processing is complete, it will call the function you specify.
0
 
LVL 7

Expert Comment

by:twol
ID: 2759450
The timer control is your answer. You must set up the timer control on the form of your background report. On form load, start the timer.

As an active X exe, the spawned program will kick off the timer and release control to your calling program immediately. When the timer event fires, it will execute the code you have placed in <object>_timer. This is where you put your report creation code. Your report production code should also have an event "Report Done" that is raised when the task is complete.

We have a process that uses this methodology to control numerous processes running at the same time.
0
 

Author Comment

by:saffron
ID: 2776719
mdougan,

Thanks I'm going to accept your comment as the answer.  Unfortunately I inadvertently posted this question twice and a suggestion similar to yours was given by 4P so I'm going to have to split the points 2-ways.  Hope this doesn't seem unfair.

Basically you were right and the key to the problem was manipulating the enabled property of the timer in order to release control back to the client.

Thanks for your help.

Saffron.
0
 
LVL 3

Expert Comment

by:darinw
ID: 2779175
Reviewing question.

darinw
Customer Service
0
 
LVL 18

Expert Comment

by:mdougan
ID: 2779409
No problem, in the future, don't be shy about asking customer service to delete the duplicate question.  Just post a comment explaining what you'd done and invite the people who'd commented to post in the other question instead.

0

Featured Post

Free Trending Threat Insights Every Day

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 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

20 Experts available now in Live!

Get 1:1 Help Now