How kill thread of backgroundworker

F

friend

Hello all,

how to "kill" or stop the thread of Backgroundworker ?

In my Dowork event, I have not set e.Cancel = true, since i only have
a call to splashscreen which says "Please Wait......".
When my process completes in the current thread, the splashscreen in
backgroundworker should go away

I am doing the cancel for backgorundworker, is by calling CancelAsync,
but the splashscreen doesnt go away

How I can do it , please ? Any suggestions will be very appreciated.

Thanks in advance.
 
F

friend

Hello all,

how to "kill" or stop the thread of Backgroundworker ?

In my Dowork event, I have not set e.Cancel = true, since i only have
a call to splashscreen which says "Please Wait......".
When my process completes in the current thread, the splashscreen in
backgroundworker should go away

I am doing the cancel for backgorundworker, is by calling CancelAsync,
but the splashscreen doesnt go away

How I can do it , please ? Any suggestions will be very appreciated.

Thanks in advance.

I am using splashscreen1.showdialog() to display the splashscreen.
 
F

friend

Hello all,

how to "kill" or stop the thread of Backgroundworker ?

In my Dowork event, I have not set e.Cancel = true, since i only have
a call to splashscreen which says "Please Wait......".
When my process completes in the current thread, the splashscreen in
backgroundworker should go away

I am doing the cancel for backgorundworker, is by calling CancelAsync,
but the splashscreen doesnt go away

How I can do it , please ? Any suggestions will be very appreciated.

Thanks in advance.

I am using splashscreen1.showdialog() to display the splashscreen.
 
C

Cor Ligthert[MVP]

Hi,

If you had set the work you had to do in a backgroundworker, then you had
made it yourself much easier.

The name is backgroundworker, not foregroundshower.

Cor
 
C

Cor Ligthert[MVP]

Hi,

If you had set the work you had to do in a backgroundworker, then you had
made it yourself much easier.

The name is backgroundworker, not foregroundshower.

Cor
 
M

Mike

friend said:
Hello all,

how to "kill" or stop the thread of Backgroundworker ?

In my Dowork event, I have not set e.Cancel = true, since i only have
a call to splashscreen which says "Please Wait......".
When my process completes in the current thread, the splashscreen in
backgroundworker should go away

I am doing the cancel for backgorundworker, is by calling CancelAsync,
but the splashscreen doesnt go away

How I can do it , please ? Any suggestions will be very appreciated.

Thanks in advance.

Maybe you have a special need in a "Splash Screen" to be in a thread,
but Splash screens are normally just *non-modal* popups with little to
no work at all, which you display and can continue with the startup
logic which at some point or delay, you close the popup.

The window (form) methods are:

MySplashForm.Show() <- displays and returns (non-modal)
MySplashForm.ShowDialog() <- displays and waits (modal)

IOW for SplashScreen concepts, you don't need a thread for that.

In the startup event (load maybe), you do:

MySplashForm.Show()

and then when ever you want to close it, you just do:

MySplashForm.Dispose()


Example: With a 10 second timer to simulate work in the main GUI
thread and when its done, it closes the splash screen. The splash
form as a Listbox so the main gui can display a startup log.

Public Class Form1
Private nTimer As Integer = 10

Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
MySplash.Show()
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick( _
ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
nTimer = nTimer - 1
MySplash.ListBox1.Items.Add(String.Format("Time {0}", nTimer))
If nTimer <= 0 Then
Timer1.Enabled = False
MySplash.Dispose()
End If
End Sub
End Class

--
 
M

Mike

friend said:
Hello all,

how to "kill" or stop the thread of Backgroundworker ?

In my Dowork event, I have not set e.Cancel = true, since i only have
a call to splashscreen which says "Please Wait......".
When my process completes in the current thread, the splashscreen in
backgroundworker should go away

I am doing the cancel for backgorundworker, is by calling CancelAsync,
but the splashscreen doesnt go away

How I can do it , please ? Any suggestions will be very appreciated.

Thanks in advance.

Maybe you have a special need in a "Splash Screen" to be in a thread,
but Splash screens are normally just *non-modal* popups with little to
no work at all, which you display and can continue with the startup
logic which at some point or delay, you close the popup.

The window (form) methods are:

MySplashForm.Show() <- displays and returns (non-modal)
MySplashForm.ShowDialog() <- displays and waits (modal)

IOW for SplashScreen concepts, you don't need a thread for that.

In the startup event (load maybe), you do:

MySplashForm.Show()

and then when ever you want to close it, you just do:

MySplashForm.Dispose()


Example: With a 10 second timer to simulate work in the main GUI
thread and when its done, it closes the splash screen. The splash
form as a Listbox so the main gui can display a startup log.

Public Class Form1
Private nTimer As Integer = 10

Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
MySplash.Show()
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick( _
ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
nTimer = nTimer - 1
MySplash.ListBox1.Items.Add(String.Format("Time {0}", nTimer))
If nTimer <= 0 Then
Timer1.Enabled = False
MySplash.Dispose()
End If
End Sub
End Class

--
 
F

friend

Maybe you have a special need in a "Splash Screen" to be in a thread,
but Splash screens are normally just *non-modal* popups with little to
no work at all, which you display and can continue with the startup
logic which at some point or delay,  you close the popup.

The window (form) methods are:

     MySplashForm.Show()        <- displays and returns (non-modal)
     MySplashForm.ShowDialog()  <- displays and waits (modal)

IOW for SplashScreen concepts, you don't need a thread for that.

In the startup event (load maybe), you do:

     MySplashForm.Show()

and then when ever you want to close it, you just do:

     MySplashForm.Dispose()

Example: With a 10 second timer to simulate work in the main GUI
thread and when  its done, it closes the splash screen.  The splash
form as a Listbox so the main gui can display a startup log.

Public Class Form1
     Private nTimer As Integer = 10

     Private Sub Form1_Load( _
               ByVal sender As System.Object, _
               ByVal e As System.EventArgs) Handles MyBase.Load
         MySplash.Show()
         Timer1.Enabled = True
     End Sub

     Private Sub Timer1_Tick(  _
               ByVal sender As Object, _
               ByVal e As System.EventArgs) Handles Timer1.Tick
         nTimer = nTimer - 1
         MySplash.ListBox1.Items.Add(String.Format("Time {0}", nTimer))
         If nTimer <= 0 Then
             Timer1.Enabled = False
             MySplash.Dispose()
         End If
     End Sub
End Class

--

Thanks to all,
I solved my problem...
 
F

friend

Maybe you have a special need in a "Splash Screen" to be in a thread,
but Splash screens are normally just *non-modal* popups with little to
no work at all, which you display and can continue with the startup
logic which at some point or delay,  you close the popup.

The window (form) methods are:

     MySplashForm.Show()        <- displays and returns (non-modal)
     MySplashForm.ShowDialog()  <- displays and waits (modal)

IOW for SplashScreen concepts, you don't need a thread for that.

In the startup event (load maybe), you do:

     MySplashForm.Show()

and then when ever you want to close it, you just do:

     MySplashForm.Dispose()

Example: With a 10 second timer to simulate work in the main GUI
thread and when  its done, it closes the splash screen.  The splash
form as a Listbox so the main gui can display a startup log.

Public Class Form1
     Private nTimer As Integer = 10

     Private Sub Form1_Load( _
               ByVal sender As System.Object, _
               ByVal e As System.EventArgs) Handles MyBase.Load
         MySplash.Show()
         Timer1.Enabled = True
     End Sub

     Private Sub Timer1_Tick(  _
               ByVal sender As Object, _
               ByVal e As System.EventArgs) Handles Timer1.Tick
         nTimer = nTimer - 1
         MySplash.ListBox1.Items.Add(String.Format("Time {0}", nTimer))
         If nTimer <= 0 Then
             Timer1.Enabled = False
             MySplash.Dispose()
         End If
     End Sub
End Class

--

Thanks to all,
I solved my problem...
 

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

Top