PC Review


Reply
Thread Tools Rate Thread

Simple app....silly question?

 
 
David Bonnell
Guest
Posts: n/a
 
      29th Oct 2008
I have a Windows Forms app that is intended to launch via the SendTo
feature. I want it to perform work (in the background) while updating
a progress bar in the main window.

The problem: I want this to run without any user interaction (except
for launching the app via SendTo).
The form is created via an Application.Run(new myForm()) call, which
then proceeds through the form constructor.

When the constructor returns and the form is displayed, I have no way
of instructing the application to "begin" work. As a workaround, I
temporarily placed a button on the form for the user to initiate work.

I must be missing something. This seems like it would be trivial to
implement. I was considering using a timer as a hack, but surely
there is a better option. Launching a worker thread before exiting
the constructor doesn't strike me as a very good idea either...

Any ideas?

 
Reply With Quote
 
 
 
 
David Bonnell
Guest
Posts: n/a
 
      29th Oct 2008
>
> I'm not sure I understand the question. *Do you not want the form to *
> display at all? *Or do you simply want things to happen while the form is *
> displayed without the user having to specifically interact with the form?
>


I want the form to display (the form should consist of only a progress
bar and possibly a status label).
As work is being done (some file manipulation), I want the progress
bar to update to give the user some feedback that the task is being
completed.
Once the task is complete, I want the application to exit.

> If the latter, then I don't see what your objection to starting a worker *
> thread in the constructor is -- that should work fine -- but if you don't*
> like that, you could instead do something similar in the form's OnLoad() *
> or OnShown() method. *


I guess I'm not a fan of doing too much in a constructor. Probably
more a lack of understanding than anything...
OnLoad/Shown seems like a good idea. I'll give it a try and see what
shakes loose.

Thanks,
Dave

 
Reply With Quote
 
 
 
 
David Bonnell
Guest
Posts: n/a
 
      30th Oct 2008
>
> I suppose that might be a consideration here. *It depends on how you *
> implement the worker thread. *But from a more general point of view, as*
> long as you're not doing something that will lead to an illegal operation, *
> I don't think that it's necessarily a bad thing to put initialization code *
> in the constructor. *It has to run _sometime_, and the constructor is in *
> fact a place where things are supposed to get initialized. *


OnShown worked like a charm. Thanks for the help.

I suspect that in this case it would work fine in the
constructor...but I am my own worst enemy. A month from now I'd
probably add more initialization to the constructor and miss some GUI
updates from the worker thread as a result.

Dave

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple questions for simple 2 PC file sharing network. Simple? raylopez99 Microsoft Windows 2000 Networking 3 11th Feb 2007 02:31 PM
Simple Simple Simple craigwojo Microsoft Excel New Users 3 29th Aug 2004 05:32 AM
Simple or not so simple animation.....? ZR Microsoft Powerpoint 1 19th May 2004 05:10 AM
Simple File Sharing (not so simple ...) Lee Bowman Windows XP Basics 1 8th Apr 2004 09:38 PM
A Simple Problem For A Simple Guy L. Gardiner Windows XP General 3 19th Aug 2003 02:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:39 AM.