Windows Forms - How Can I Make Them Draw/Render Properly?

  • Thread starter Thread starter Joey Powell
  • Start date Start date
J

Joey Powell

Hello all. For a long time now I have been struggling with a .net
Windows Forms problem. In several of my applications, I use the
"Process" class from System.Diagnostics to accomplish various task
from within my code (kind of like the old VB shell function). Using
this process class appears to be just one example of what causes my
Windows forms to look really crazy when running the application. In
fact this has become not only a cosmetic issue but also a usability
issue as of late. Users are confused because the application is not
updating or appears to be not responding.

More specifically, when I say that the forms look crazy what I mean
is, that quite frequently:

* The forms will draw white and not update for several minutes.

* My application will have two or three windows open in the Windows
taskbar when there should only be one.

It's as if there is a lot of processing waiting to occur but it can't
for some reason (maybe because the app is tied up working with the
shelled processes?) Even then, though, it doesn't update between the
processes! It doesn't update between the processes, even though (in
despiration) I have included numerous calls to the form's "Activate",
"Show", and "Refresh" functions.

I am tired of this causing problems. I would really like to know what
I can do to prevent it from happening in the future. Somebody once
told me it had something to do with threading, but I don't know about
that. Does anyone have any suggestions on what I should do?
 
Joey,

This is not a Windows Forms issue. Rather, this is probably an issue
about how you are instantiating the Process and calling Start on it. First,
the call should be on another thread, so that it does not interfere with the
responsiveness of the app. Second, how are you making the call?
 
Nichlolas I am pretty sure that the processes are not on separate
threads...how does one do that anyway? You see, it's important that
app fire the processes syncronously - one can not run until the one
before it has finished...you know what I mean. That why I am using the
"Start" function along with the "WaitForExit" function of the process
class. I also call the "Dispose" function for each after I am
completely finished with the process. Now how can one accomplish the
syncronous processing while keeping the GUI updating properly?

Nicholas Paldino said:
Joey,

This is not a Windows Forms issue. Rather, this is probably an issue
about how you are instantiating the Process and calling Start on it. First,
the call should be on another thread, so that it does not interfere with the
responsiveness of the app. Second, how are you making the call?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Joey Powell said:
Hello all. For a long time now I have been struggling with a .net
Windows Forms problem. In several of my applications, I use the
"Process" class from System.Diagnostics to accomplish various task
from within my code (kind of like the old VB shell function). Using
this process class appears to be just one example of what causes my
Windows forms to look really crazy when running the application. In
fact this has become not only a cosmetic issue but also a usability
issue as of late. Users are confused because the application is not
updating or appears to be not responding.

More specifically, when I say that the forms look crazy what I mean
is, that quite frequently:

* The forms will draw white and not update for several minutes.

* My application will have two or three windows open in the Windows
taskbar when there should only be one.

It's as if there is a lot of processing waiting to occur but it can't
for some reason (maybe because the app is tied up working with the
shelled processes?) Even then, though, it doesn't update between the
processes! It doesn't update between the processes, even though (in
despiration) I have included numerous calls to the form's "Activate",
"Show", and "Refresh" functions.

I am tired of this causing problems. I would really like to know what
I can do to prevent it from happening in the future. Somebody once
told me it had something to do with threading, but I don't know about
that. Does anyone have any suggestions on what I should do?
 
That's what Nicolas was trying to say.
Because you call WaitForExit you're blocking the thread from updating the
GUI.
That's why you have to run these tasks on a different threads. Running it on
a different thread has nothing to do with accomplishing tasks in a specific
synchronious order. You can still do this, just on a different thread.

Greetz,
-- Rob.

Joey said:
Nichlolas I am pretty sure that the processes are not on separate
threads...how does one do that anyway? You see, it's important that
app fire the processes syncronously - one can not run until the one
before it has finished...you know what I mean. That why I am using the
"Start" function along with the "WaitForExit" function of the process
class. I also call the "Dispose" function for each after I am
completely finished with the process. Now how can one accomplish the
syncronous processing while keeping the GUI updating properly?

"Nicholas Paldino [.NET/C# MVP]"
Joey,

This is not a Windows Forms issue. Rather, this is probably an
issue
about how you are instantiating the Process and calling Start on it.
First,
the call should be on another thread, so that it does not interfere
with the
responsiveness of the app. Second, how are you making the call?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Joey Powell said:
Hello all. For a long time now I have been struggling with a .net
Windows Forms problem. In several of my applications, I use the
"Process" class from System.Diagnostics to accomplish various task
from within my code (kind of like the old VB shell function). Using
this process class appears to be just one example of what causes my
Windows forms to look really crazy when running the application. In
fact this has become not only a cosmetic issue but also a usability
issue as of late. Users are confused because the application is not
updating or appears to be not responding.

More specifically, when I say that the forms look crazy what I mean
is, that quite frequently:

* The forms will draw white and not update for several minutes.

* My application will have two or three windows open in the Windows
taskbar when there should only be one.

It's as if there is a lot of processing waiting to occur but it
can't
for some reason (maybe because the app is tied up working with the
shelled processes?) Even then, though, it doesn't update between the
processes! It doesn't update between the processes, even though (in
despiration) I have included numerous calls to the form's
"Activate", "Show", and "Refresh" functions.

I am tired of this causing problems. I would really like to know
what
I can do to prevent it from happening in the future. Somebody once
told me it had something to do with threading, but I don't know
about
that. Does anyone have any suggestions on what I should do?
 
Have a look at my article on codeproject.com
http://www.codeproject.com/useritems/LaunchProcess.asp

and also this really good article on threading and UI's
http://msdn.microsoft.com/msdnmag/issues/03/02/Multithreading/default.aspx


--
Mike Mayer
http://www.mag37.com/csharp/
(e-mail address removed)




Rob Tillie said:
That's what Nicolas was trying to say.
Because you call WaitForExit you're blocking the thread from updating the
GUI.
That's why you have to run these tasks on a different threads. Running it on
a different thread has nothing to do with accomplishing tasks in a specific
synchronious order. You can still do this, just on a different thread.

Greetz,
-- Rob.

Joey said:
Nichlolas I am pretty sure that the processes are not on separate
threads...how does one do that anyway? You see, it's important that
app fire the processes syncronously - one can not run until the one
before it has finished...you know what I mean. That why I am using the
"Start" function along with the "WaitForExit" function of the process
class. I also call the "Dispose" function for each after I am
completely finished with the process. Now how can one accomplish the
syncronous processing while keeping the GUI updating properly?

"Nicholas Paldino [.NET/C# MVP]"
Joey,

This is not a Windows Forms issue. Rather, this is probably an
issue
about how you are instantiating the Process and calling Start on it.
First,
the call should be on another thread, so that it does not interfere
with the
responsiveness of the app. Second, how are you making the call?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hello all. For a long time now I have been struggling with a .net
Windows Forms problem. In several of my applications, I use the
"Process" class from System.Diagnostics to accomplish various task
from within my code (kind of like the old VB shell function). Using
this process class appears to be just one example of what causes my
Windows forms to look really crazy when running the application. In
fact this has become not only a cosmetic issue but also a usability
issue as of late. Users are confused because the application is not
updating or appears to be not responding.

More specifically, when I say that the forms look crazy what I mean
is, that quite frequently:

* The forms will draw white and not update for several minutes.

* My application will have two or three windows open in the Windows
taskbar when there should only be one.

It's as if there is a lot of processing waiting to occur but it
can't
for some reason (maybe because the app is tied up working with the
shelled processes?) Even then, though, it doesn't update between the
processes! It doesn't update between the processes, even though (in
despiration) I have included numerous calls to the form's
"Activate", "Show", and "Refresh" functions.

I am tired of this causing problems. I would really like to know
what
I can do to prevent it from happening in the future. Somebody once
told me it had something to do with threading, but I don't know
about
that. Does anyone have any suggestions on what I should do?
 
Back
Top