PC Review


Reply
Thread Tools Rate Thread

Loading data after form loads

 
 
Sean Patterson
Guest
Posts: n/a
 
      24th Dec 2004
Greets all,

I have a little scan gun app that loads a bunch of text files into some
data tables for reference. Currently, I have the loading method occur on
the MyBase.Load event within the app.

Since there is a lot of processing going on, typically I click the
executable on the device, the wait cursor is displayed, and I have this
odd looking screen until the files load.

I was wondering if there is a way to run the method after all of the GUI
stuff loads, so that way I can update a status label and make the
loading a little prettier.

Thanks in advance for any insight you may have!
 
Reply With Quote
 
 
 
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      24th Dec 2004
In the load event just before you start your lengthy operation, add
Application.DoEvents();
If you want to update progress, also add the above after every update.
Having said that I need to point out that this kind of things is better done
in a background worker thread.

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Sean Patterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Greets all,
>
> I have a little scan gun app that loads a bunch of text files into some
> data tables for reference. Currently, I have the loading method occur on
> the MyBase.Load event within the app.
>
> Since there is a lot of processing going on, typically I click the
> executable on the device, the wait cursor is displayed, and I have this
> odd looking screen until the files load.
>
> I was wondering if there is a way to run the method after all of the GUI
> stuff loads, so that way I can update a status label and make the loading
> a little prettier.
>
> Thanks in advance for any insight you may have!



 
Reply With Quote
 
Sergey Bogdanov
Guest
Posts: n/a
 
      24th Dec 2004
as Alex suggested the long operations is better to implement as
background process. Below is a code snippet how it could be done:

TestForm()
{ System.Threading.ThreadPool.QueueUserWorkItem(
new System.Threading.WaitCallback(Run));
}

void SafeRun(object sender, EventArgs e)
{
// here could be updating progress bar
}

void Run(object o)
{
bool completed = false;
while(!completed)
{
//long processing iteration
this.Invoke(new EventHandler(SafeRun));
}
}


Sean Patterson wrote:
> Greets all,
>
> I have a little scan gun app that loads a bunch of text files into some
> data tables for reference. Currently, I have the loading method occur on
> the MyBase.Load event within the app.
>
> Since there is a lot of processing going on, typically I click the
> executable on the device, the wait cursor is displayed, and I have this
> odd looking screen until the files load.
>
> I was wondering if there is a way to run the method after all of the GUI
> stuff loads, so that way I can update a status label and make the
> loading a little prettier.
>
> Thanks in advance for any insight you may have!

 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      24th Dec 2004
Try doing it on a separate thread. The BackgroundWorker could be useful:
http://www.danielmoth.com/Blog/2004/...for-cf-10.html

The above link also includes the VB source. The C# (identical) version is
here:
http://www.opennetcf.org/sourcebrows...roundWorker.cs

Application.DoEvents also helps in some cases but I generally don't
recommend it.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Sean Patterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Greets all,
>
> I have a little scan gun app that loads a bunch of text files into some
> data tables for reference. Currently, I have the loading method occur on
> the MyBase.Load event within the app.
>
> Since there is a lot of processing going on, typically I click the
> executable on the device, the wait cursor is displayed, and I have this
> odd looking screen until the files load.
>
> I was wondering if there is a way to run the method after all of the GUI
> stuff loads, so that way I can update a status label and make the loading
> a little prettier.
>
> Thanks in advance for any insight you may have!



 
Reply With Quote
 
Sean Patterson
Guest
Posts: n/a
 
      27th Dec 2004
Thanks to all three of you for the heads up! I'll DEFINITELY be getting
that thread action going! Hope you all had a happy holiday!

- Sean

Daniel Moth wrote:
> Try doing it on a separate thread. The BackgroundWorker could be useful:
> http://www.danielmoth.com/Blog/2004/...for-cf-10.html
>
> The above link also includes the VB source. The C# (identical) version is
> here:
> http://www.opennetcf.org/sourcebrows...roundWorker.cs
>
> Application.DoEvents also helps in some cases but I generally don't
> recommend it.
>
> Cheers
> Daniel

 
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
Switchboard usage preventing my form loading data form my database =?Utf-8?B?RWFtb25u?= Microsoft Access Getting Started 4 7th Sep 2006 10:46 PM
Transfer data to form from Excel range upon loading of form. =?Utf-8?B?Um9iIENyYXdmb3Jk?= Microsoft Excel Programming 2 24th Oct 2005 04:59 PM
Clear Form data withour re-loading form jmawebco Microsoft Access Form Coding 2 28th Sep 2005 07:50 PM
Waiting untill the Web Form loads,while loading showing something else.. Nicholas Paldino [.NET/C# MVP] Microsoft C# .NET 3 22nd Oct 2003 09:18 PM
getting data from a bound control when form first loads L Melville Microsoft Access Form Coding 2 19th Aug 2003 04:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:36 PM.