|
-
Jul 9th, 2014, 03:33 PM
#1
Thread Starter
New Member
VB 2013 Application Eating Memory!
Hi All,
So I started coding VB last week. I posted here a couple of times, but went away, did some homework and built what I wanted to build... Still with some help along the way.
Anyway, in pursuit of improvements I wanted to add a progress bar. But it struggled to update. I then learnt that I should use a background worker to perform the actual operation and leave the UI thread to update the progress bar. I did this, but my app seriously degraded. During one load I got a runtime out of memory error.
I then learnt that I had poor implementation of the background worker as I was trying to cross-thread and pull information from the controls on the form. I'm working to resolve this, but as a test I removed the background worker but the app still performed in the same manner. At a loss I started with a new form and planned to add all code back in slowly to see where the issue was. Anyway I fell at the first hurdle with a form load sub that restored the controls states from those on closing. Below is the code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' FORM 1.
' Initialise specialised string collections.
If My.Settings.StartNameListBoxItems1 Is Nothing Then
My.Settings.StartNameListBoxItems1 = _
New System.Collections.Specialized.StringCollection
End If
If My.Settings.StartNameListBoxSelectedItems1 Is Nothing Then
My.Settings.StartNameListBoxSelectedItems1 = _
New System.Collections.Specialized.StringCollection
End If
' TAB PAGE 1.
' Restore controls from saved settings.
StartPathTextBox1.Text() = My.Settings.StartPathTextBox1
ZipPathTextBox1.Text() = My.Settings.ZipPathTextBox1
CopyPathTextBox1.Text() = My.Settings.CopyPathTextBox1
ZipSelectCheckBox1.Checked = My.Settings.ZipSelectCheckBox1
CopySelectCheckBox1.Checked = My.Settings.CopySelectCheckBox1
For Each s As String In My.Settings.StartNameListBoxItems1()
StartNameListBox1.Items.Add(s)
Next
For Each s As String In My.Settings.StartNameListBoxSelectedItems1()
StartNameListBox1.SelectedItems.Add(s)
Next
' Decide controls initial states.
If StartNameListBox1.SelectedItems.Count = 0 Then
ZipSelectCheckBox1.Enabled = False
RunButton1.Enabled = False
End If
If ZipSelectCheckBox1.Checked = False Then
ZipPathTextBox1.Enabled = False
ZipBrowseButton1.Enabled = False
End If
If ZipPathTextBox1.Text = String.Empty Then
CopySelectCheckBox1.Enabled = False
End If
If CopySelectCheckBox1.Checked = False Then
CopyPathTextBox1.Enabled = False
CopyBrowseButton1.Enabled = False
End If
End Sub
Can anyone see an issue? Thing is it was working before introducing the background worker, but now with the background worker removed it doesn't work. I'm at a loss. I'll fix the issue with cross threading by packing all the controls together in a single object to feed into the background worker (If anyone has some examples I would be grateful, but I have an idead so stick with the main issue) but I have no idea why my app no longer works. Can anyone pick up a connection here or is there any settings I should know about when saving variables in the apps settings. Thanks for reading!
UPDATE: I should add that I removed all the saves to settings for persistence and the app works. If I add back in then I get a problem. I still can't fathom the problem as a previous app worked with this save to my settings.
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
|