Should I use "Invoke" for this goal?
Hi. Due to running a bunch of try catches, wmi and Performance counters, A form load event will take a lot of time to be done. (Like a massive loop) I'm already using BackgroundWorker for other purposes but I assume that Form load event is better to take a tangible visual.
I only want to set Me.Cursor = Cursors.Wait or Me.UseWaitCursor = True . (By the way, What are the differences between these two? What should I use)
Then reset it to default only for user to understand the app is still responding and PC is not "hang". Unfortunately 2 mentioned ways were tried and no waiting cursors occurred. I read somewhere BeginInvoke (And EndInvoke) can make this happen, but how?
Re: Should I use "Invoke" for this goal?
You shouldn’t use Form_Load for that type of large loop. Use the Form’s Constructor so the code is run before the form is loaded
Re: Should I use "Invoke" for this goal?
Thanks .paul. so the order would be constructor, load, shown right? What about user controls? They do not have such event. Plus, my problem seems a synchronous %CPU high load thing how can I overcome it? For instance showing a messagebox in this stage opens it semi-transparency. Box is not completely displayed (Corresponding audio also won't play) until that heavy load passes, everything back to normal.
Re: Should I use "Invoke" for this goal?
I immediately regretted my decision. By constructor you mean
Code:
Public Class MYUSERCONTROL
Public Sub New()
Me.InitializeComponent()
End Sub
Private Sub InitializeComponent()
End Sub
End Class
?
If so, what is the correct way to write it down? Cause I already have errors:
1) BC30269 'Private Sub InitializeComponent()' has multiple definitions with identical signatures.
2) BC30521 Overload resolution failed because no accessible 'InitializeComponent' is most specific for these arguments:
'Private Sub InitializeComponent()': Not most specific.
'Private Sub InitializeComponent()': Not most specific.
Re: Should I use "Invoke" for this goal?
May I also draw your attention to this part, partially?
Quote:
Originally Posted by
pourkascheff
Me.Cursor = Cursors.Wait or Me.UseWaitCursor = True . (By the way, What are the differences between these two? What should I use)
Re: Should I use "Invoke" for this goal?
Quote:
Originally Posted by
pourkascheff
I immediately regretted my decision. By constructor you mean
Code:
Public Class MYUSERCONTROL
Public Sub New()
Me.InitializeComponent()
End Sub
Private Sub InitializeComponent()
End Sub
End Class
?
If so, what is the correct way to write it down? Cause I already have errors:
1) BC30269 'Private Sub InitializeComponent()' has multiple definitions with identical signatures.
2) BC30521 Overload resolution failed because no accessible 'InitializeComponent' is most specific for these arguments:
'Private Sub InitializeComponent()': Not most specific.
'Private Sub InitializeComponent()': Not most specific.
There should already be a sub InitializeComponents() in the .designer file of the form... no need for you to create one. Any initialization code you want to add should go after the Me.InitialzeComponent() call in the constructor.
Code:
Public Class MYUSERCONTROL
Public Sub New()
Me.InitializeComponent()
' Add additional code here
End Sub
' Private Sub InitializeComponent()
' Removed this
' End Sub
End Class
-tg