Hi
Here is one example of hundreds of thousands possibilities.
This is just an example, and no error checking.
Form1 image and code below.
Form2 (named PleaseWait) has a PictureBox1, and code below.
A .gif image needs to be placed in a folder named 'Data' which is located in the same place as the executable (say Debug folder or Release folder depending on mode being used), and the file name edited in imPath variable to suit.
The example uses a BackGroundWorker which stops the main Form from being blocked while PleaseWait is being shown.
Form1
Option Strict On
Option Explicit On
Imports System.ComponentModel
Public Class Form1
Dim WithEvents bgw As New BackgroundWorker
Dim PW As New PleaseWait
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
bgw.WorkerSupportsCancellation = True
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' show please wait form
If Not bgw.IsBusy Then
PW = New PleaseWait
PW.Show()
'start operation
bgw.RunWorkerAsync()
Else
' user stopping operation
bgw.CancelAsync()
End If
End Sub
Private Sub bgw_DoWork(sender As Object, e As DoWorkEventArgs) Handles bgw.DoWork
' this sub emulates some long
' running operaion
Dim c As Integer = 0
Do
'show progress
Invoke(Sub() Label1.Text = c.ToString)
'emulate the operation with
' a dummy 'pause'
Threading.Thread.Sleep(1000)
'increase counter
c += 1
' stop if user cancels OR the
' counter reaches limit
Loop Until bgw.CancellationPending Or c > 15
End Sub
Private Sub bgw_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles bgw.RunWorkerCompleted
' stopped by user or counter
Label1.Text = "Stopped"
' dispose of PleaseWait Form
PW.Dispose()
End Sub
End Class
EDIT: forgot the code for PleaseWait Form
Option Strict On
Option Explicit On
Public Class PleaseWait
Dim imPath As String = IO.Path.Combine(Application.StartupPath, "Data", "Running.gif")
Private Sub PleaseWait_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.Image = Image.FromFile(imPath)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
End Class