|
-
Jun 14th, 2007, 03:40 AM
#1
Thread Starter
Junior Member
How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
How Can I apply Threading in multiple forms
One of my forms consist of around 100 controls so it took 30 seconds to navigate to that form
I use form.showDialog() to show that form then close it by Me.close(0
I dont Know where to place threading in my application code
-
Jun 14th, 2007, 06:42 AM
#2
Frenzied Member
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
Hi,
I don't understand what threading has to do with this? Are you trying to speed up the load of your form? If must be doing something else to take 30 seconds to load. Presumably these controls are in panels or similar?
What is it doing in the load procedure - reading from a database, populating combo boxes?
Pete
-
Jun 14th, 2007, 07:46 AM
#3
Thread Starter
Junior Member
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
In the Load event of my one form, 10 adapters fill my type datasets
I also bind the specific column of the datatables of the datasets to populate
data in the comboboxes
Also that form has many panels and Tab controls and within are sorts of textboxes,label,etc
Can I apply threading in the Initialize component of the form while filling the datasets? If it is possible how?
All my forms are inhereted in a Template Form to reuse the Clock header
This is the code of my template class
Code:
Public Class TemplateForm
Protected Friend Sub TemplateForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
UpdateClock()
End Sub
Protected Friend Sub ClockTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClockTimer.Tick
UpdateClock()
End Sub
Private Sub UpdateClock()
Me.TimeLabel.Text = Format(Now, "h:mm tt")
Me.DateLabel.Text = Format(Now, "M/d/yyyy")
End Sub
Private Sub TemplateForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not NextForm Is Nothing Then
NextForm.Visible = True
End If
End Sub
Private _nextForm As TemplateForm
Public Property NextForm() As TemplateForm
Get
Return Me._nextForm
End Get
Set(ByVal value As TemplateForm)
Me._nextForm = value
End Set
End Property
I set the project startup of my project to sub main() within a module
Code:
Sub Main()
'Upon startup
Dim curForm As TemplateForm = New LoginForm
Dim nextForm As TemplateForm
'To save PocketPC memory, we'll make sure that only one
'form will be in memory at any given time. Once a form
'activates another form, that current form is closed and
'unloaded, while the new form is loaded and activated.
'In case some data needs to be exchanged between forms,
'we will pass a data object in the forms where they can
'read and store data. That object will be managed by this
'instance. The forms should be responsible for cleaning up
'the data they store in this object.
Do
curForm.ShowDialog()
If Not curForm.NextForm Is Nothing Then
nextForm = curForm.NextForm
curForm = nextForm
Else 'if set to Nothing, then exit the program
Exit Do
End If
Loop
End Sub
I call my child forms on this code
Code:
Private Sub LoginMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Me.NextForm = New MainMenuForm ' Call the other form, same logic
'applies with other forms
Me.Close()
End If
End Sub
-
Jun 14th, 2007, 07:49 AM
#4
Thread Starter
Junior Member
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
I want to speed up the load of the next form
-
Jun 14th, 2007, 07:50 AM
#5
Thread Starter
Junior Member
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
I want to sped up the load of the next form
In the Load event of my one form, 10 adapters fill my type datasets
I also bind the specific column of the datatables of the datasets to populate
data in the comboboxes
Also that form has many panels and Tab controls and within are sorts of textboxes,label,etc
Can I apply threading in the Initialize component of the form while filling the datasets? If it is possible how?
All my forms are inhereted in a Template Form to reuse the Clock header
This is the code of my template class
Code:
Public Class TemplateForm
Protected Friend Sub TemplateForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
UpdateClock()
End Sub
Protected Friend Sub ClockTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClockTimer.Tick
UpdateClock()
End Sub
Private Sub UpdateClock()
Me.TimeLabel.Text = Format(Now, "h:mm tt")
Me.DateLabel.Text = Format(Now, "M/d/yyyy")
End Sub
Private Sub TemplateForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not NextForm Is Nothing Then
NextForm.Visible = True
End If
End Sub
Private _nextForm As TemplateForm
Public Property NextForm() As TemplateForm
Get
Return Me._nextForm
End Get
Set(ByVal value As TemplateForm)
Me._nextForm = value
End Set
End Property
I set the project startup of my project to sub main() within a module
Code:
Sub Main()
'Upon startup
Dim curForm As TemplateForm = New LoginForm
Dim nextForm As TemplateForm
'To save PocketPC memory, we'll make sure that only one
'form will be in memory at any given time. Once a form
'activates another form, that current form is closed and
'unloaded, while the new form is loaded and activated.
'In case some data needs to be exchanged between forms,
'we will pass a data object in the forms where they can
'read and store data. That object will be managed by this
'instance. The forms should be responsible for cleaning up
'the data they store in this object.
Do
curForm.ShowDialog()
If Not curForm.NextForm Is Nothing Then
nextForm = curForm.NextForm
curForm = nextForm
Else 'if set to Nothing, then exit the program
Exit Do
End If
Loop
End Sub
I call my child forms on this code
Code:
Private Sub LoginMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Me.NextForm = New MainMenuForm ' Call the other form, same logic
'applies with other forms
Me.Close()
End If
End Sub
-
Jun 14th, 2007, 09:31 AM
#6
Frenzied Member
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
Hi,
use a splash screen, and load your typed datasets in sub main, then they are available throughout your project.
I suspect that is what is taking the time, loading the datasets, not loading the form
Pete
-
Jun 14th, 2007, 09:37 AM
#7
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
I agree, those datasets are killers for speed. In theory, you could load them on a separate thread, but what would it gain you? You still wouldn't be able to use the form until all that loading was completed, so you would still be waiting.
If you can find something useful to do with the time, such that the datasets can load in the background while something meaningful is happening without that data, then that is a good alternative, but it is rarely possible. Because of a similar issue with a shopping list program, I saved the current list to a text file so that I could toss the current list up in a splash screen that looked like the main program, while I loaded the lists from the DB in the background. Once the main form was ready, I replaced the splash with the main form, but until that happened, the user could see the list, but not change anything. This is almost exactly what Petevick was suggesting. It really doesn't do a thing to speed up the loading of the program (in fact, it slowed it by one second in my tests), but it sped up the time to first use, which was good enough for me.
Whether or not you can do anything like that is up to your understanding of your particular problem.
My usual boring signature: Nothing
 
-
Jun 14th, 2007, 12:03 PM
#8
Thread Starter
Junior Member
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
But I used Typed Dataset, I design it before I run my appz.
how Do i include it in the Sub main()?
I think the reason why i took 30 seconds to load one of my forms is the number of Controls on the form. I test it without the dataset and it is the same.
I heard that using stack could be a possible solution.
But I don't know how to implement it.
-
Jun 14th, 2007, 02:35 PM
#9
Frenzied Member
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
Hi,
I just knocked up a form with 120 controls on it, and it takes 7 seconds to show and load if i run it from explorer. If i make it the 2nd form, and do a showdialog of it from the 1st form, it takes 3 seconds.
I suggest you take a close look at what is happening in your code.
Pete
-
Jun 14th, 2007, 04:13 PM
#10
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
I have forms with a few dozen controls located on panels that were being swapped in and out of the view screen. I don't think I ever bothered to time the loading, but I suspect that it would time out around what Pete showed, as his timing is suspiciously similar to another app that I DID time. However, I narrowed that other app down to the DB connection taking time.
How are you displaying things? Dozens of controls shouldn't normally be a problem, but it seems like it might cause problems if all the controls were shown, then hidden in one of a small variety of possible ways.
My usual boring signature: Nothing
 
-
Jun 15th, 2007, 04:44 AM
#11
Thread Starter
Junior Member
-
Jun 15th, 2007, 09:43 AM
#12
Re: How To Apply Threading in Loading controls??[Mobile 5.0 VB2005]
Unfortunately, that picture came through so small that I can't read anything on it. I'm not sure if that is important. How many forms do you have? If it is more than one, search this forum on Panels. You might search for my user name, as I have certainly talked about the subject often enough. Basically, loading forms in the CF is too slow, so I put everything onto panels, and swap panels in and out of the view plane, which has no lag at all. If you are already doing that, then that suggestion was not exactly helpful.
My usual boring signature: Nothing
 
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
|