473,382 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How do I prevent my progress dialog getting locked up?

7
Hi there :)

Here are some infos about my "project":
I have the "honor" to write some scripts (VBScript) for some application developed by another company. In this application there is limited support for creating and showing dialogs. But the customers want it. So we have to create those dialogs in class libraries to be able use them in the scripts.

Until now, we had ActiveX/COM libraries created with VB6.0. But now, the customers want us to port them to .NET.

And here is my problem:
I ported some sort of progress dialog into the .NET world. It runs fine... as long as no one wants a "cancel" button.

The progress dialog should be accessible from the script like this:
Expand|Select|Wrap|Line Numbers
  1. Dim intIndex
  2. Dim objDialog
  3. Set objDialog = CreateObject("ProgressBar.Dialog")
  4.  
  5. 'setup dialog
  6. Call objDialog.SetCaption("Test")
  7. Call objDialog.ShowCancelButton(True)
  8.  
  9. 'show dialog
  10. Call objDialog.Show()
  11.  
  12. 'do some work in a loop
  13. Do While WorkIsAvailable()
  14.     Call DoWork()
  15.     If objDialog.IsCanceled() Then
  16.         Exit Sub
  17.     End If
  18.     Call objDialog.advanceProgress()
  19. Loop
  20.  
  21. 'hide dialog
  22. Call objDialog.Hide()
  23.  
  24.  
So I created a dialog form like this:
Expand|Select|Wrap|Line Numbers
  1. // (C# code; limited to the attributes and methods that seem important to me)
  2.  
  3. public partial class Dialog : Form
  4. {
  5.     private bool _isCanceled = false;
  6.  
  7.     public void advanceProgress() {
  8.         this.progressBar.Increment(1);
  9.     }
  10.  
  11.     private void cmdCancel_Click(object sender, EventArgs e) {
  12.         this.cmdCancel.Enabled = false;
  13.         this._isCanceled = true;
  14.     }
  15.  
  16.     public bool isCanceled() {
  17.         return this._isCanceled;
  18.     }
  19. }
  20.  
As said. This works. But the dialog seems to get too busy, handling GUI requests like pushing that "cancel" button, which is important.

Inserting "WScript.sleep(1)" in my test script running from desktop solved the problem, but "WScript" is not available in that application the script should run in.

And I think it would be better, to have the dialog form "lockup-save", instead of adding some pause in each script.

While searching for answers, I got some info about background workers and threads (they seem to be like those in JAVA), but I don't think, these can help me here, since I can't execute my work in a seperate thread. If I could tell the GUI to run in another thread... ;)

Well, perhaps someone of you guys can help me with this one ;)

Thanks & have a nice day :)

Lawyno
Oct 30 '08 #1
3 1537
Lawyno
7
No expert here, who could help me? :'(
Nov 6 '08 #2
IanWright
179 100+
Well you could add in Application.DoEvents() within the threading loop...

However that isn't a very nice solution. The more important question really is why can't you do the work in a seperate thread?
Nov 6 '08 #3
Lawyno
7
Well you could add in Application.DoEvents() within the threading loop...
Application.DoEvents() works really nice, thank you ;)

However that isn't a very nice solution. The more important question really is why can't you do the work in a seperate thread?
Well the work is done (and can only be done) by the script. So how could I put that work into a seperate Thread? Unfortunately I can't tell the host application to do so.
Nov 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ben | last post by:
I have looked around for this but I seem to be missing something. I have a forum based on a query that brings display some table info in tabular form. What I would like to do is prevent the user...
3
by: Gary O'Malley | last post by:
Everytime I download a file from the web I get a nice animated dialogue box that shows the size of the file, how much has been received and the approximate remaining time. It also gives the...
4
by: Scott Lundstrom | last post by:
I have a large amount of data I'm dropping into a dataset and would like to find a way to at the very least show the user that the program is working at retrieving the data and not locked up. I...
4
by: Alexander | last post by:
Hi, I have written a program that takes on some operations much more time than I expected. As I have seen users clicking wildly on the screen to make something happen, I want to follow the...
1
by: Ziggy | last post by:
Please excuse this elementary question...but I am just dumb.... I have taken a simplistic Dialog Box and added a Progress Control. When I did that, my Dialog Box was no longer able to intialize...
7
by: Pepi Tonas | last post by:
I have a form that takes some time to load because it has to populate some Data. I was trying to display a form on top of it with an activity bar so that user can see that something's going on. ...
5
by: B-Dog | last post by:
I'm trying to build a custom progress bar that will run as some subs are running in the background but when I open the custom form with the progress bar on it using the showdialog, none of the subs...
2
by: Michael Jervis | last post by:
Hi, I'm writing a little application that scans a large number of media files for processing. The main application currently uses a backgroundworkerprocess to perform the scan. Each media...
5
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.