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
- Dim intIndex
- Dim objDialog
- Set objDialog = CreateObject("ProgressBar.Dialog")
- 'setup dialog
- Call objDialog.SetCaption("Test")
- Call objDialog.ShowCancelButton(True)
- 'show dialog
- Call objDialog.Show()
- 'do some work in a loop
- Do While WorkIsAvailable()
- Call DoWork()
- If objDialog.IsCanceled() Then
- Exit Sub
- End If
- Call objDialog.advanceProgress()
- Loop
- 'hide dialog
- Call objDialog.Hide()
Expand|Select|Wrap|Line Numbers
- // (C# code; limited to the attributes and methods that seem important to me)
- public partial class Dialog : Form
- {
- private bool _isCanceled = false;
- public void advanceProgress() {
- this.progressBar.Increment(1);
- }
- private void cmdCancel_Click(object sender, EventArgs e) {
- this.cmdCancel.Enabled = false;
- this._isCanceled = true;
- }
- public bool isCanceled() {
- return this._isCanceled;
- }
- }
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