Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / August 2005

Tip: Looking for answers? Try searching our database.

Problem about the multithreading

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alien - 31 Aug 2005 13:52 GMT
hi guys
i have a problem regarding using multithreading in the cf1.0. i tried to
load some data from the sqlce database then fill them into a datagrid.
before i used the thread, my code likes following

private void LoadDataFromDB()
{
   //
   // Select statement
   // Load some
   //
}

then
private void FillDataGrid(){

//
// some instructions.
//
}

everything working fine at this stage. except load data takes some time, it
will cause the whole application ui stop response for some time.
so i decide to use thread to load the data.
but after i use a new thread to perform the load data action.
 private void DoEvent()
 {
  ThreadStart starter = new ThreadStart(LoadDataFromDB);
  Thread t = new Thread(starter);
  t.Start();
 }
And call the DoEvent instead of calling LoadDataFromDB. but something goes
wrong here. my cursor seems go forever. and nothing had been filled into
the datagrid.

Can anyone help me on this?? Please tell me a correct way to do this.

thank you
cheers
Alex Yakhnin [MVP] - 31 Aug 2005 14:57 GMT
Make sure that you're using Control.Invoke when updating the grid.

--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com | www.opennetcf.org

> hi guys
> i have a problem regarding using multithreading in the cf1.0. i tried to
[quoted text clipped - 35 lines]
> thank you
> cheers
Alien - 31 Aug 2005 23:25 GMT
is that mean i should use
threadstarter starter = new threadstarter (loaddata())
thread t = new thread(starter)
t.start

then i use
this.invoke(filldatagird()) to update the datagird?

is that right?

> Make sure that you're using Control.Invoke when updating the grid.
>
[quoted text clipped - 43 lines]
>> thank you
>> cheers
Chris Tacke, eMVP - 31 Aug 2005 14:58 GMT
Are you filling the datagrid through a call to Invoke?  If not, that would
be the problem.

Signature

Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF?  Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate

> hi guys
> i have a problem regarding using multithreading in the cf1.0. i tried to
[quoted text clipped - 35 lines]
> thank you
> cheers

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.