Hello Everyone,
Just curious how far off the mark I am with my Working Dialog. Any
improvements are welcomed.
Scenario, we have an application (vb'05) that at known times performs tasks
that take some time to process. During those times, I would like to display
a dialog that informs the user that work is occuring.
We have a base form that all other forms derive from. It is in this form
that I put the logic for enabling and disabling the wait dialog.
Here is a simple sample use:
class form1
inherits baseForm
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
showDelay()
Me.Button1.Enab led = False
Dim aList As ArrayList = New ArrayList
For i As Integer = 1 To 10
For j As Integer = 1 To 10000
'Hurt the processor
aList.Add(i)
Application.DoE vents()
Next
Debug.Print(i.T oString)
Next
Me.Button1.Enab led = True
endDelay()
MsgBox("Job's Done!")
End Sub
end class
Here is my code
'--==Class baseForm.vb==--
Protected f As splashForm
Protected inDelay As Boolean
Private Sub showDelay()
If inDelay Then Exit Sub
inDelay = True
Dim imageFirst As System.Drawing. Bitmap
Dim imagesecond As System.Drawing. Bitmap
Dim myStream As System.IO.Strea m
Dim thisExe As System.Reflecti on.Assembly
thisExe = System.Reflecti on.Assembly.Get EntryAssembly
myStream =
thisExe.GetMani festResourceStr eam(String.Form at("{0}.imageFi rst.bmp",
thisExe.GetName .Name))
imageFirst = System.Drawing. Bitmap.FromStre am(myStream)
myStream =
thisExe.GetMani festResourceStr eam(String.Form at("{0}.imageSe cond.bmp",
thisExe.GetName .Name))
imagesecond = System.Drawing. Bitmap.FromStre am(myStream)
f = New splashForm(imag eFirst, imagesecond)
f.Show(Me)
f.Process(False )
End Sub
Private Sub endDelay()
If inDelay Then
f.Stop()
f.Dispose()
End If
inDelay = False
End Sub
'--===Class splashForm.vb==--
Public Class splashForm
Private EndDelay As Boolean
Private OnFirst As Boolean = True
Private imageFirst As System.Drawing. Bitmap
Private imageSecond As System.Drawing. Bitmap
Public Sub New(ByVal oimageFirst As System.Drawing. Bitmap, ByVal
oimageSecond As System.Drawing. Bitmap)
' This call is required by the Windows Form Designer.
InitializeCompo nent()
' Add any initialization after the InitializeCompo nent() call.
imageFirst = oimageFirst
imageSecond = oimageSecond
Me.BackgroundIm age = imageFirst
EndDelay = False
End Sub
Public Sub [Stop]()
EndDelay = True
End Sub
Public Sub Process(Optiona l ByVal ShowProcessing As Boolean = True)
Dim worker As System.Componen tModel.Backgrou ndWorker
worker = New System.Componen tModel.Backgrou ndWorker
worker.WorkerRe portsProgress = True
worker.WorkerSu pportsCancellat ion = True
If ShowProcessing Then
Me.BackgroundIm age = imageSecond
Else
Me.BackgroundIm age = imageFirst
End If
AddHandler worker.Progress Changed, AddressOf progressChanged
AddHandler worker.RunWorke rCompleted, AddressOf runWorkerComple ted
AddHandler worker.DoWork, AddressOf doWork
EndDelay = False
worker.RunWorke rAsync()
End Sub
Private Sub doWork(ByVal sender As Object, ByVal e As
System.Componen tModel.DoWorkEv entArgs)
'Temp var used as a flag
Dim DontStop As Boolean
' Get the BackgroundWorke r object that raised this event.
Dim worker As System.Componen tModel.Backgrou ndWorker = CType(sender,
System.Componen tModel.Backgrou ndWorker)
DontStop = True
Do While DontStop
SyncLock (Me)
DontStop = Not EndDelay
End SyncLock
'Trace.WriteLin e(String.Format ("Processing and dontstop = {0}",
DontStop.ToStri ng))
worker.ReportPr ogress(0)
Threading.Threa d.Sleep(50)
Loop
End Sub
Private Sub progressChanged (ByVal sender As Object, ByVal e As
System.Componen tModel.Progress ChangedEventArg s)
Static GoNorth As Boolean
If Not EndDelay Then
If Me.Opacity >= 1D Then GoNorth = False
If Me.Opacity <= 0.01D Then GoNorth = True
If GoNorth Then
Me.Opacity += 0.05D
Else
Me.Opacity -= 0.05D
End If
Me.CenterToPare nt()
End If
End Sub
Private Sub runWorkerComple ted(ByVal sender As Object, ByVal e As
System.Componen tModel.RunWorke rCompletedEvent Args)
Dim worker As System.Componen tModel.Backgrou ndWorker = CType(sender,
System.Componen tModel.Backgrou ndWorker)
RemoveHandler worker.Progress Changed, AddressOf progressChanged
RemoveHandler worker.RunWorke rCompleted, AddressOf runWorkerComple ted
RemoveHandler worker.DoWork, AddressOf doWork
End Sub
End Class 0 1092 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rich Tasker |
last post by:
I have a strange situation. A simple call to MessageBox.Show("XXX", "YYY")
does not display the message in the messagebox with a visible font. Based on
the content of the messagebox, the box sizes properly so I know there is a
message in there. I also found a keyboard shortcut where <ctrl>+<insert>
will copy the contents of the messagebox to the clipboard in plain text. I
see my messagebox text in the clipboard contents but not in the...
|
by: Sherwood |
last post by:
Greetings,
I have a "newbie" question regarding C#.NET. I am using the "Windows
Application" template and am simply trying to display a second form
("frmInstructions") once the user clicks a command button on the main form.
In the "Click" event of the command button, I have the following code:
Application.Run(new frmInstructions());
I have also tried "frmInstructions.ActiveForm.Show", but neither are
|
by: Walid Koleilat |
last post by:
I have created an assembly and assigned a strong name to it. However I want
to reference it from another application and i want its name to appear in
the add reference dialog box,
I think I should add a some kind of a registry value but i don't know where
and what value.
a second question, I heard about Asp.net 2.0 and visual studio 2005
does it mean that they will also change the MCSD soon?
and If you are MCSD what are you going to do...
|
by: sonic |
last post by:
Hi,
displaying information on a page as MS Word document seems to be as
simple as:
//OnLoad
Response.ContentType = "application/msword";
Response.Write ( MyContentString );
(this assuming intranet site environment with users ensured to use
certain version of MS Word on their workstations)
|
by: mpreston |
last post by:
I'm following the example from the MSDN library on how to create modal dialog
boxes in C#, but something isn't working properly. If I create a modal
dialog box and show it using ShowDialog(), the main form behind the dialog
box is still enabled and can operate normally. If I use MessageBox.Show() to
show a message box, the main form is disabled until the dialog box
terminates. How can I make a custom dialog box do this?
| |
by: Andrew Kidd |
last post by:
Hi,
I've just been working through several examples of how to create Master
pages and then create content pages which are linked, but I cannot see the
Master page when I'm viewing the content page in "Design", nor do I see it
when I'm viewing the page in the browser.
I'm adding the Master page through the Add New Item dialog, and creating Web
Forms with the "Select Master Page" option checked, then selecting the
Master page from the...
|
by: henning |
last post by:
Hello, I'm involved in the development of a set of web pages that are
meant to be used on touch screens.
We use ordinary HTML, PHP and javascript for the pages. I wold prefer a
serverside solution, but we also have access to the clients so if it's
not possible a clientside solution would be acceptable. All clients use
Internet explorer (version may vary, but probably 6 or 7).
What I would like to accomplish is a <buttonto print the...
|
by: NBKMNDN |
last post by:
Hi frends,
In my C# application im creating a new excel sheet and im inserting some data into this excel sheet, and im trying to save the file with the help of method SAVE AS. But it doesnot displays save dialog while it is saving.
how to save the excel file by displaying save dialog in c#.
THANK U .
|
by: Michael Bray |
last post by:
I'm trying to display an image on an ATL Dialog form in VS2003... I think
I am able to load an image (a GIF) w/ CImage.Load, and I'm trying to call
the SetBitmap followed by Invalidate on the CStatic that I get, but no
image appears... I'm doing this in OnInitDialog(...). any help?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |