Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Multithreading Process in VB.Net

Posted on 2004-09-29
8
Medium Priority
?
334 Views
Last Modified: 2008-03-04
Hi all!

When my form loads, i need fill a dataset with some data from a oracle database. The server needs about 30 secs to return the results that i will use to fill my dataset.

But, i don't whan't to wait for the filling process end to be able to work with my form, so, i'm thinking using a thread to the fill process, and call this thread from my form_load event.

I created a class that will be used to fill the dataset. This class has the method called filldts.
When the form_load event is called, the thread is called and started, but, my form doesn't appear until the thread ends.

Does anyvody can show me a example of how implement this?

Thanks all!
0
Comment
Question by:regisdaniel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 256 total points
ID: 12184247
You just need to make the form show and refresh itself before starting your thread:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim delayedLoadTime As DateTime

        Me.Show()    ' force the form to show and update itselft
        Me.Refresh() ' before going into the long process

        delayedLoadTime = DateTime.Now().AddSeconds(10)
        While DateTime.Now < delayedLoadTime
            ' man this form loads slow...
        End While
    End Sub

~IM
0
 
LVL 2

Expert Comment

by:GohdanTheMoblin
ID: 12184316
How are you starting the thread, and how does it interact with the for?.  Threads aren't my specialty, but if the dataset is already bound to a control like a DataGrid, this could be part of the problem.  If this is the case, try binding the control after the thread has completed.
0
 
LVL 14

Assisted Solution

by:ptakja
ptakja earned 248 total points
ID: 12186134
I suggest downloading & installing the 101 VB.Net Code Samples from the MSDN website:

http://www.microsoft.com/downloads/details.aspx?FamilyId=08E3D5F8-033D-420B-A3B1-3074505C03F3&displaylang=en

It covers a bunch of stuff, one part of which is threading.
0
 
LVL 19

Assisted Solution

by:arif_eqbal
arif_eqbal earned 248 total points
ID: 12187581
See if you have called a new thread and filling the data in this thread your form will show parallelly but the issue is Rendering form on screen takes its time so the main thread should be given sufficient time to show the form. So you can set the Priority of the new thread to say BelowNormal

Thread1.Priority=Threading.ThreadPriority.BelowNormal

May be it can help
0
 
LVL 8

Assisted Solution

by:wguerram
wguerram earned 248 total points
ID: 12190202
After showing the form call:

dim f as new form1
f.Show
f.Refresh
Application.DoEvents
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question