473,388 Members | 1,286 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,388 software developers and data experts.

Dialogue form remains visible during program execution

Ger
My dialogue form (sometimes partly, sometimes as a whole) remains visible
during a fairly long processing job.
The dialogue asks the user to enter some data for the job to follow, and
after OK, should disappear and the processing job (Sub CreateHTML()) starts,
while showing a progress bar in the main form.
The problem is that the dialogue form stays visible and does not close
during execution of the job. It closes after the job is finished.
What am I doing wrong? Should I start a separate thread for the processing
job, or is there a more simple solution I am not aware of yet? Code below:

Dim fh As New frmHTML
If fh.ShowDialog(Me) = DialogResult.OK Then
'save dialogue data:
'(not relevant I think, but left it in for clearity)
DBDirectory = Directory.GetCurrentDirectory
HLang = fh.cmbLanguage.Text
HMainOnly = fh.radMain.Checked
HVarCols = Val(fh.txtCols.Text)
DBDirectory = fh.txtOutput.Text
fh.Dispose() 'Get rid of the dialogue form (I thought......)
' do the processing job:
CreateHTML()
Else
fh.Dispose()
End if

Thank you for replying.
/Ger
Nov 21 '05 #1
12 1525
Ger wrote:
My dialogue form (sometimes partly, sometimes as a whole) remains visible
during a fairly long processing job.
The dialogue asks the user to enter some data for the job to follow, and
after OK, should disappear and the processing job (Sub CreateHTML()) starts,
while showing a progress bar in the main form.
The problem is that the dialogue form stays visible and does not close
during execution of the job. It closes after the job is finished.
What am I doing wrong? Should I start a separate thread for the processing
job, or is there a more simple solution I am not aware of yet? Code below:

Dim fh As New frmHTML
If fh.ShowDialog(Me) = DialogResult.OK Then
'save dialogue data:
'(not relevant I think, but left it in for clearity)
DBDirectory = Directory.GetCurrentDirectory
HLang = fh.cmbLanguage.Text
HMainOnly = fh.radMain.Checked
HVarCols = Val(fh.txtCols.Text)
DBDirectory = fh.txtOutput.Text
fh.Dispose() 'Get rid of the dialogue form (I thought......)
' do the processing job:
CreateHTML()
Else
fh.Dispose()
End if

Thank you for replying.
/Ger

Try inserting an application.doevents right after the dispose. That
gives the app the time to clean up the graphics.

Rinze
Nov 21 '05 #2
Ger,

In my opinion your program should work, did you try it with another dialog
form with by instance only this on it?

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.DialogResult = DialogResult.OK
End Sub

Just to try the effect?

Cor
"Ger" <ge*********@rathernospam.sailsoft.nl>
My dialogue form (sometimes partly, sometimes as a whole) remains visible
during a fairly long processing job.
The dialogue asks the user to enter some data for the job to follow, and
after OK, should disappear and the processing job (Sub CreateHTML())
starts,
while showing a progress bar in the main form.
The problem is that the dialogue form stays visible and does not close
during execution of the job. It closes after the job is finished.
What am I doing wrong? Should I start a separate thread for the processing
job, or is there a more simple solution I am not aware of yet? Code below:

Dim fh As New frmHTML
If fh.ShowDialog(Me) = DialogResult.OK Then
'save dialogue data:
'(not relevant I think, but left it in for clearity)
DBDirectory = Directory.GetCurrentDirectory
HLang = fh.cmbLanguage.Text
HMainOnly = fh.radMain.Checked
HVarCols = Val(fh.txtCols.Text)
DBDirectory = fh.txtOutput.Text
fh.Dispose() 'Get rid of the dialogue form (I thought......)
' do the processing job:
CreateHTML()
Else
fh.Dispose()
End if

Thank you for replying.
/Ger

Nov 21 '05 #3
Rinze,

The dispose does not close the form, it should give the resources back to
the GC, however I am more and more in doubt if that it is needed. A form
created with the designer implements Idisposable, so it should do it itself.

However there is a MSDN page that tells that only forms showed with show
will be disposed. But it is for me absolute not clear what with that is
meant. I am more and more in doubt if that page is telling about a form that
not implements IDisposable and is made directly by code.

(Therefore I am really curious if your recommendation will help)

Just my thought,

Cor
"C-Services Holland b.v." <cs*@REMOVEcsh4u.nl>
Ger wrote:
My dialogue form (sometimes partly, sometimes as a whole) remains
visible
during a fairly long processing job.
The dialogue asks the user to enter some data for the job to follow, and
after OK, should disappear and the processing job (Sub CreateHTML())
starts,
while showing a progress bar in the main form.
The problem is that the dialogue form stays visible and does not close
during execution of the job. It closes after the job is finished.
What am I doing wrong? Should I start a separate thread for the
processing
job, or is there a more simple solution I am not aware of yet? Code
below:

Dim fh As New frmHTML
If fh.ShowDialog(Me) = DialogResult.OK Then
'save dialogue data:
'(not relevant I think, but left it in for clearity)
DBDirectory = Directory.GetCurrentDirectory
HLang = fh.cmbLanguage.Text
HMainOnly = fh.radMain.Checked
HVarCols = Val(fh.txtCols.Text)
DBDirectory = fh.txtOutput.Text
fh.Dispose() 'Get rid of the dialogue form (I thought......)
' do the processing job:
CreateHTML()
Else
fh.Dispose()
End if

Thank you for replying.
/Ger

Try inserting an application.doevents right after the dispose. That gives
the app the time to clean up the graphics.

Rinze

Nov 21 '05 #4
Ger
Cor,
Thank you for your reply. Your example works fine, as other dialogues in my
application do also. But in all these cases the applications awaits further
user interactivity after handling the dialogue, so there is time enough to
close the dialogue.
The problem however seems to be here that the framework (or windows?) is
very busy processing the job (createhtml), and has no time to close the
dialogue form until the job is done. I do not know how to deal with that,
apart from running the job in a separate thread.
Thanks anyway,
/Ger
"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:uB**************@TK2MSFTNGP10.phx.gbl...
Ger,

In my opinion your program should work, did you try it with another dialog
form with by instance only this on it?

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.DialogResult = DialogResult.OK
End Sub

Just to try the effect?

Cor
"Ger" <ge*********@rathernospam.sailsoft.nl>
My dialogue form (sometimes partly, sometimes as a whole) remains visible during a fairly long processing job.
The dialogue asks the user to enter some data for the job to follow, and
after OK, should disappear and the processing job (Sub CreateHTML())
starts,
while showing a progress bar in the main form.
The problem is that the dialogue form stays visible and does not close
during execution of the job. It closes after the job is finished.
What am I doing wrong? Should I start a separate thread for the processing job, or is there a more simple solution I am not aware of yet? Code below:
Dim fh As New frmHTML
If fh.ShowDialog(Me) = DialogResult.OK Then
'save dialogue data:
'(not relevant I think, but left it in for clearity)
DBDirectory = Directory.GetCurrentDirectory
HLang = fh.cmbLanguage.Text
HMainOnly = fh.radMain.Checked
HVarCols = Val(fh.txtCols.Text)
DBDirectory = fh.txtOutput.Text
fh.Dispose() 'Get rid of the dialogue form (I thought......)
' do the processing job:
CreateHTML()
Else
fh.Dispose()
End if

Thank you for replying.
/Ger


Nov 21 '05 #5
Ger

"C-Services Holland b.v." <cs*@REMOVEcsh4u.nl> schreef in bericht
news:ju********************@zeelandnet.nl...
Ger wrote:
My dialogue form (sometimes partly, sometimes as a whole) remains visible during a fairly long processing job.
Try inserting an application.doevents right after the dispose. That
gives the app the time to clean up the graphics.

Rinze


Thank you Rinze, that did the trick! But I inserted the doevents statement
just before the sub (createhtml) is executed, not after the dispose as you
suggest, and it works OK now. Thanks again.

Nov 21 '05 #6
Ger,

When what you say is true, than you can use the information from Rinze

However set than directly after your dialog.OK then that
application.doevents.
I doubt about it however you never know and "Niet geschoten is altijd
misgeschoten".

I tested it because I am curious as well and have placed on that place a
threading.thread.sleep(3000), the dialogform did disapear however directly.

Can you show some code from your dialogform?

(I do not think that multithreading is a solution in this, with that it can
be even more difficult to let it disapear).

Cor

"Ger" <ge*********@rathernospam.sailsoft.nl>
....
Cor,
Thank you for your reply. Your example works fine, as other dialogues in
my
application do also. But in all these cases the applications awaits
further
user interactivity after handling the dialogue, so there is time enough to
close the dialogue.
The problem however seems to be here that the framework (or windows?) is
very busy processing the job (createhtml), and has no time to close the
dialogue form until the job is done. I do not know how to deal with that,
apart from running the job in a separate thread.
Thanks anyway,
/Ger
"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:uB**************@TK2MSFTNGP10.phx.gbl...
Ger,

In my opinion your program should work, did you try it with another
dialog
form with by instance only this on it?

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.DialogResult = DialogResult.OK
End Sub

Just to try the effect?

Cor
"Ger" <ge*********@rathernospam.sailsoft.nl>
> My dialogue form (sometimes partly, sometimes as a whole) remains visible > during a fairly long processing job.
> The dialogue asks the user to enter some data for the job to follow,
> and
> after OK, should disappear and the processing job (Sub CreateHTML())
> starts,
> while showing a progress bar in the main form.
> The problem is that the dialogue form stays visible and does not close
> during execution of the job. It closes after the job is finished.
> What am I doing wrong? Should I start a separate thread for the processing > job, or is there a more simple solution I am not aware of yet? Code below: >
> Dim fh As New frmHTML
> If fh.ShowDialog(Me) = DialogResult.OK Then
> 'save dialogue data:
> '(not relevant I think, but left it in for clearity)
> DBDirectory = Directory.GetCurrentDirectory
> HLang = fh.cmbLanguage.Text
> HMainOnly = fh.radMain.Checked
> HVarCols = Val(fh.txtCols.Text)
> DBDirectory = fh.txtOutput.Text
> fh.Dispose() 'Get rid of the dialogue form (I thought......)
> ' do the processing job:
> CreateHTML()
> Else
> fh.Dispose()
> End if
>
> Thank you for replying.
> /Ger
>
>



Nov 21 '05 #7
Ger,

I did not read this message before I sand mine.

:-)

Cor
Nov 21 '05 #8
Ger,

Wrong place so again

I did not read this message before I sand mine where is almost the same said
to try.

:-)

Cor

Nov 21 '05 #9
Cor Ligthert wrote:
Rinze,

The dispose does not close the form, it should give the resources back to
the GC, however I am more and more in doubt if that it is needed. A form
created with the designer implements Idisposable, so it should do it itself.

However there is a MSDN page that tells that only forms showed with show
will be disposed. But it is for me absolute not clear what with that is
meant. I am more and more in doubt if that page is telling about a form that
not implements IDisposable and is made directly by code.

(Therefore I am really curious if your recommendation will help)

Just my thought,

Cor


AFAIK disposing means releasing all resources, thus it should also be
removed from the graphics part. But since a CPU intensive task was
started right away, the OS didn't get time to clean up the graphics
plane so what was left was merely an echo of the form. Calling DoEvents
lets the OS handle those events and redrawing/updating the screen.

At least that's how I understand what is happening :)

Rinze
Nov 21 '05 #10
Rinze,

When there is no reference anymore to it, so that is why I did not say it
would not work, however when the form is on screen and there is no reference
anymore to it, would be very strange in my opinion..

Cor
Nov 21 '05 #11
Ger
Cor,

However set than directly after your dialog.OK then that
application.doevents.
I doubt about it however you never know and "Niet geschoten is altijd
misgeschoten". True! Rinzes solution worked for me.

I tested it because I am curious as well and have placed on that place a
threading.thread.sleep(3000), the dialogform did disapear however directly.
Can you show some code from your dialogform?

The dialogue form asks the user to enter a file name and a few selection
options.
After clicking OK the application starts reading a large database
sequentially with datareader. During this process a html file is created, as
well as the required gif images in separate image files. This process is
indeed very CPU intensive, so I guess Rinze's conclusion is correct. It
probably also depends on the processor speed and available memory and other
resources.
Thank you Cor for your replies.
/Ger


Nov 21 '05 #12
I have an application that imports XML & CSV databases and whenever I would
select a very large file to proccess the OpenFile Dialog would hang until
the proccess was completed. I tried the Application.DoEvents and it worked
great!! Made all the difference in the world.
Glad you posted this, I was pulling my hair out (what little I have left)
trying to figure out how to fix this.
james

"Ger" <ge*********@rathernospam.sailsoft.nl> wrote in message
news:OZ**************@TK2MSFTNGP09.phx.gbl...
Cor,

However set than directly after your dialog.OK then that
application.doevents.
I doubt about it however you never know and "Niet geschoten is altijd
misgeschoten".

True! Rinzes solution worked for me.

I tested it because I am curious as well and have placed on that place a
threading.thread.sleep(3000), the dialogform did disapear however

directly.

Can you show some code from your dialogform?

The dialogue form asks the user to enter a file name and a few selection
options.
After clicking OK the application starts reading a large database
sequentially with datareader. During this process a html file is created,
as
well as the required gif images in separate image files. This process is
indeed very CPU intensive, so I guess Rinze's conclusion is correct. It
probably also depends on the processor speed and available memory and
other
resources.
Thank you Cor for your replies.
/Ger

Nov 21 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Raposa Velha | last post by:
Hello to all! Does any of you want to comment the approach I implement for instantiating a form? A description and an example follow. Cheers, RV jmclopesAThotmail.com replace the AT with the...
3
by: JavaConvert | last post by:
I would like to create form that simply hold textboxes that I log info to during the execution of a single-thread application. In Java, I found JFrame ideal for the task, but I can't recreate the...
6
by: John | last post by:
Hi Is there a way to open a form hidden/invisible while it is populating its controls, and then make it visible once it is done? I am using the following code but the form remains visible. ...
2
by: Rich | last post by:
Can a vb.net form contain a subform? If yes, how is this done? Maybe I am going about my issue the wrong way. I start an asynchronous procedure from my main form - invoke a routine on a...
6
by: Thelma Lubkin | last post by:
I am trying to modify an Access form that allows a user to specify the information s/he needs from a census-type database. The form's code builds a SQL statement from the user's request, and...
4
by: Graham Charles | last post by:
Hello, I'm finding that if I set the "Cancel" property during the AppStartup event, the application's Splash form remains loaded. A call to the Close property of the SplashForm at that point...
2
by: Arman Sahakyan | last post by:
Hi, While writing code for creating aspx controls dynamically, I noticed some strange (at least to me) behavior. Look at this code; // FreeQuery : System.Web.UI.Page // void cmdDo_Click(...)...
3
by: Gilberto | last post by:
Hello, I have a form with some buttons that take the user to reports, other forms, etc. On this form the user can see how many products are missing costing and pricing information, through some...
6
by: ewokspy | last post by:
I have a C# program in 2003 that creates a reminder bubble (windows form) to remind a user to pick up their printout. The bubbles show up fine, and they have 2 buttons, a yes and a snooze. The yes...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.