|
-
Jul 19th, 2023, 08:09 AM
#1
Thread Starter
Hyperactive Member
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?
-
Jul 19th, 2023, 09:02 AM
#2
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 20th, 2023, 12:00 AM
#3
Thread Starter
Hyperactive Member
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.
-
Jul 20th, 2023, 12:17 AM
#4
Thread Starter
Hyperactive Member
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.
Last edited by pourkascheff; Jul 20th, 2023 at 12:33 AM.
-
Jul 20th, 2023, 01:44 AM
#5
Thread Starter
Hyperactive Member
Re: Should I use "Invoke" for this goal?
May I also draw your attention to this part, partially?
 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)
-
Jul 20th, 2023, 06:51 AM
#6
Re: Should I use "Invoke" for this goal?
 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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|