Monday, September 05, 2005 5:47 PM
Using VB.NET 2005 - Beta 2,
I've created a Windows Form Application with a single form and several new Classes and now I am trying to separate them and make a .dll out of the custom classes.
I created a new "Class Module" project and used "Add Existing Item" to select each of the custom class.vb files.
Some of the methods attached to my custom classes take a while to run and so I had coded them interspersed with "windows.form.application.doevents()" statements.
Now that there is no form in my new project, these lines are generating errors that "Application" is not a member of "Forms".
So my question is:
How can I add a 'Doevents()' to methods in my class library?
Thanks in advance...
Monday, September 05, 2005 6:25 PMModeratorYou need to add a reference to System.Windows.Forms.dll.
Tuesday, September 06, 2005 4:18 AMThis is one way of doing it, but it is not really the best way.
You are better off using threads to do it (and sleeping the thread to save CPU for long running tasks).
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myThread As New System.Threading.Thread(AddressOf myLongTask)
// Do something else, thread will start in its own sweet time
Private Sub myLongTask()
Dim TaskFinished As Boolean
// Do lots of stuff
Loop Until TaskFinished = True
And threading is a whole new world full of stuff that needs to be learnt...
Tuesday, September 06, 2005 6:43 AMI'm using a lot the instruction Thread now on Framework 1.1. Very simple to use and you can get more than a single task running. Pls read tha manual written by Francesco Balena (Microsoft press) in order to get more informations