Activity Bar

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I have found an Activity Bar control which looks to be exactly what I
need for my splash screen, but I can't seem to get it working. When I
initialise the Start method, the application bar works great until I
do any other processing, which is when it freezes! There is no
documentation with the control which I downloaded from:

http://www.gotdotnet.com/Community/...mpleGuid=7B0E2EAB-42C4-47AA-9292-731052946BD5

I have tried creating my own thread to initialise the Start method,
but it makes no difference. I am probably missing something really
basic here or there is a bug in the control, which I can't believe as
what's the point of an activity bar that freezes during activity? If
anyone can help or point me towards other activity bar controls that
would be great.

Cheers
 
Steve,

This is not a Activity Bar however two methods in a sample I made to show
two methods for a splash screen that does not freeze.

\\\needs on form 1 one button and three textboxes
Private WithEvents frm1 As Form2
Private Delegate Sub Frm1Handler(ByVal message As String)
Private WithEvents frm2 As Form2
Private MyThread As System.Threading.Thread
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim timer1 As New System.Windows.Forms.Timer
AddHandler timer1.Tick, AddressOf mytimer1
TextBox1.Text = "0"
timer1.Enabled = True
timer1.Interval = 400
Dim timer2 As New System.Windows.Forms.Timer
End Sub
Private Sub mytimer1(ByVal sender As Object, _
ByVal e As System.EventArgs)
TextBox1.Text = (CInt(TextBox1.Text) + 1).ToString
DirectCast(sender, System.Windows.Forms.Timer).Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
frm1 = New Form2
frm1.itstop = Me.Top
frm1.itsleft = Me.Left + 200
AddHandler frm1.ready, AddressOf Frm1Ready
frm1.Text = "Extra thread"
MyThread = New System.Threading.Thread(AddressOf frm1.Show)
MyThread.Start()
frm2 = New Form2
frm2.itstop = Me.Top
frm2.itsleft = Me.Left + 400
frm2.Text = "In own thread"
AddHandler frm1.ready, AddressOf Frm2Ready
frm2.Show()
End Sub
Private Sub Frm1Ready(ByVal message As String)
Me.BeginInvoke(New Frm1Handler(AddressOf Frm1HandlerSub), New
Object() {message})
End Sub
Private Sub Frm1HandlerSub(ByVal message As String)
TextBox2.Text = message
frm1.Close()
MyThread.Abort()
End Sub
Private Sub frm2ready(ByVal message As String)
TextBox3.Text = message
frm2.Dispose()
End Sub
///
\\\Needs a form2 with one textbox
Friend Event form2ready(ByVal message As String)
Friend itstop As Integer
Friend itsleft As Integer
Private Sub Form2_Activated(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Activated
Me.Left = itsleft
Me.Top = itstop
Me.BringToFront()
Dim timenext As DateTime = Now.Add(TimeSpan.FromSeconds(10))
Do While timenext > Now
TextBox1.Text = Now.TimeOfDay.ToString
Application.DoEvents() 'to show the time
Threading.Thread.Sleep(50)
Me.Opacity -= 0.004
Loop
RaiseEvent form2ready(Now.TimeOfDay.ToString)
End Sub
Private Sub Form2_Closing(ByVal sender As Object, ByVal _
e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
e.Cancel = True
End Sub
///

I hope this helps a little bit?

Cor
 
The code in Activity Bar control calls Form.Refresh from a non-UI thread. As
far as I know, Refresh in turn updates the window immediately without going
through the message queue. In other words, the code is accessing the UI
directly from a non-UI thread which is the one thing you must not do.

For information on how to fix this, see Jon Skeet's Windows Forms
multithreaded programming FAQ:
http://www.yoda.arachsys.com/csharp/multithreading.html#windows.forms

Regards,
Sami
 
Back
Top