Using Multi-threading

  • Thread starter Thread starter simchajoy2000
  • Start date Start date
S

simchajoy2000

Hi,

I am designing an interface which allows users to load certain files
into the interface. While the file is loading, I want to display a
VB.NET form with the list of messages generated during the process. I
want the form to be displayed during the loading process and the
messages to appear one after another as they are generated in the
back-end. I'm pretty sure I need to use multi-threading for this but
I am having a lot of trouble figuring out how to do it.

I think part of my problem might be that the function which displays
the form and adds the messages to the form gets called on an
as-needed-basis instead of in a step-by-step process.

Does anyone have any advice or ideas on how I can approach this
problem??

Thanks!!

Joy
 
If this is a windows application you can just create a splash screen that
has a status bar that you change. The splach screen loads all the objects
and then shows the main form. It would be best to do this inside a main
method in a seperate class.

<STAThread()> _

Shared Sub Main()

Dim frm As New frmMain

Dim frmSplash As New SplashScreen

frmSplash.Show()

frm.LoadMemory(True, frmSplash.StatusBar1)

frm.LoadLocationData(frmSplash.StatusBar1)

frm.LoadWellMobileData(frmSplash.StatusBar1)

frm.LoadCallSheetData(frmSplash.StatusBar1)

frm.LoadForm(frm)

frmSplash.Close()

' Call the Application class' Run method

' passing it the Form1 object created above.

Application.Run(frm)

End Sub
 
I'm not sure this is what you are talking about but I just did something
similar with uploading to an ftp site. Basically what I did is created a
progress form that had a status property and then had this in click of the
upload button
oProgress = new progress
oProgress.Status = "Connecting"
oProgress.Show
ftpThread = New System.threading.thread(addressof UploadFTP)

then in my UploadFTP method I had this

oProgress.status = "Uploading File A"
'Upload file A
oProgress.status = "Uploading File B"
'Upload file B
oProgress.status = "Uploading File C"
'Upload file C
oProgress.status = "Uploading File D"
'Upload file D

This kept the program from looking like it was "Not Responding" and allowed
me to add a cancel button also.
 
Basically that is exactly what I am trying to do but the difference is
that I don't know what the status messages will be in advance. So I
can't create a function that says "write this, then write this, etc."
The messages are generated as I load the file - for that reason I have a
function that handles the event of a status message being generated. In
this function I take the message and place it in the form to display to
the user.

Is there anyway to make it so that the every time I place a message in
the form = 1 thread??

Thanks!

Joy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top