I am trying to build an application that exports a datagridview to excel. That bit's easy, but I wanted a 'please wait with animated gif' to display whilst it does. After a lot of trying different things, I eventually got that to work by wrapping the thread in a class. However, I would now like to add a cancel button to the please wait form, but I just can't get it to work. I don't know how to pass the message back to the class from the threaded form, and then from the class to the main form.
Form 1
Dim WaitDisplay As New WaitClass()
WaitDisplay.SetParent(Me)
Dim t As Thread
t = New Thread(AddressOf WaitDisplay.PleaseWait)
t.Start()
Export_Excel(DatagridView1)
t.abort()
Public Class WaitClass
Dim owner As Form1
Public Sub SetParent(ByVal parent As Form1)
owner = parent
End Sub
Public Sub PleaseWait()
Dim Please_Wait As New WaitScreen
Please_Wait.ShowDialog()
End Sub
End Class
Separate Form - just has text that says please wait with an animated gif.
Public NotInheritable Class WaitScreen
Private Sub WaitScreen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Can anyone help?
Form 1
Dim WaitDisplay As New WaitClass()
WaitDisplay.SetParent(Me)
Dim t As Thread
t = New Thread(AddressOf WaitDisplay.PleaseWait)
t.Start()
Export_Excel(DatagridView1)
t.abort()
Public Class WaitClass
Dim owner As Form1
Public Sub SetParent(ByVal parent As Form1)
owner = parent
End Sub
Public Sub PleaseWait()
Dim Please_Wait As New WaitScreen
Please_Wait.ShowDialog()
End Sub
End Class
Separate Form - just has text that says please wait with an animated gif.
Public NotInheritable Class WaitScreen
Private Sub WaitScreen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Can anyone help?