Form gets blank but still calculates.

Hakan

New member
Joined
Dec 3, 2006
Messages
4
Programming Experience
1-3
Hi

My application calculates a great number of varibles in functions that calls themselves.
My problem is that when the application is calculating and for exampel i minmize it and then activates it again i cant make any selections or view my progressbars in the form.

I run VB.NET 7.0 and only one form.

I would like to "redraw" the form everytime i get thru some loop and by that make the form "visible" and interactive.

I´ve tried me.focus and alot of me. but nothing helps.

Thanks for a great site.
 
try putting Application.DoEvents() at the end of the loop so the form is given time to update

or you could try putting the calculations into a separate thread by making your own class, then simply use events to update the form (the main thread) from the 2nd thread
 
Thanks a thousand.


I have made som threads and they work well but this is a much better solution because the user is not supposed to change, just watch the progress.


I have som problems though with
System.OutOfMemoryException.
I cant get the hang of what it is that triggers them. Sometimes its from one piece of code and sometime its from another, and this even though i run the same type of calculations.
I get more frequently this exception the first time i run and then i just hit the button again and it runs fine.
Why is that?

Andersson
 
it would depend on what type(s) of calculations the app is doing, it also depends on how many threads you're running at once with those calculations too
 
Hi
and thanks for answer
Only one thread, the main application
Type of calculations:
well my applications purpose is to calculate the most efficient combination of different length of steel tubes to fit on a specified length.

I do this by bilding a tree. Ex.
Total lenght of tube: 6450mm (a lot of these tube in this lenght)
This lengths are to be cut from the tube:s:
st Lenght(mm)
8 4880
8 1235
6 888

I put these in a listview and start whith number 1 (listview(0))
Builds first the root. Next create a child to the left thats the same value as the parent(root). recurseevly (? spelling) i add nodes to the left till the sum gets to big. When the sum gets to big i go back to the childs parent and adds one to the right.
Every left is the same index in listview(n) and every right is Listview(n+1)
(never mind the dots, they are just to display the tree.)
............4880
.........1235 4880 (to long)
.......888 1235
....888 888 1235
....... .. . 888 1235(to long)

In every family of the tree i calculate the lenght and compare to the tube.
One family in the tree does not affect the other in the same run. its the total sum that specifies how close to the lenght it can come.
To test all possible solutions before we decrease the listview and adds one solution, i have to change the value of the root.
This i do by change the order in the listview and keep track of which order has the best solution. This solution decreases the listview and then we go again until the hole listview is divided into tubes.
Hope you understand.

When i have over 7 different tube-lenghts and lets say at least 10 of each length the calculation is starting to be time/processor consuming.
This is where the system out of memory starts to happend.

/Andersson
 
so basically you're doing a bunch of length calculations and storing each set (tree node) in a whole bunch of ListViewItems?

that may be the issue right there, although I'm not certain how many of those ListViewItems you would need to create a lack of memory problem, perhaps JohnH or jmchilleny would know, i'll PM them asking for their help
 
If you are calling a routine recursively then my guess is that your problem is there. We are going to need to see the code for the routine though.
 
Hi

I cut out the most important code for my function.

I have a linked list of results (not listviews) but in every node there is one or more listviews with at most 10 rows in each.

/Andersson
 

Attachments

  • h.txt
    18.8 KB · Views: 17
Back
Top