How would one receive a value from a function while it is running?
Constantly returning a value from a funtion
Page 1 of 12 Replies - 438 Views - Last Post: 12 May 2009 - 07:58 PM
Replies To: Constantly returning a value from a funtion
#2
Re: Constantly returning a value from a funtion
Posted 12 May 2009 - 06:49 PM
Well the idea is that once you return you leave the function. That is the thought behind what a function is, takes some input, does some calculations and returns the result. It would be like asking how do you return PI while you are executing a function to calculate the area of a circle. Doesn't make a whole lot of sense.
Now if you are looking to do something over and over again on a timed basis, then you could simply use a timer control to call a function (or return a variable value). For that look into the timer_tick event of the timer control. This event is fired every so many X milliseconds based on the interval you give the timer.
But as far as returning a value from a function as it is doing something else is not the way things work.
Perhaps you can show us what you are looking to do.
Now if you are looking to do something over and over again on a timed basis, then you could simply use a timer control to call a function (or return a variable value). For that look into the timer_tick event of the timer control. This event is fired every so many X milliseconds based on the interval you give the timer.
But as far as returning a value from a function as it is doing something else is not the way things work.
Perhaps you can show us what you are looking to do.
#3
Re: Constantly returning a value from a funtion
Posted 12 May 2009 - 07:58 PM
Is this a kinda what your trying to do?
Imports System.Threading Module Program Private int_PassOut As Integer private obj_Lock as New Object Sub Main() ThreadPool.QueueUserWorkItem(new WaitCallback(addressof work),nothing) While True SyncLock(obj_lock) Console.WriteLine(Int_passOut) End SyncLock Thread.Sleep(300) End While End Sub Private Sub Work() While True SyncLock(obj_Lock) int_passOut+= 1 End SyncLock Thread.Sleep(150) End While End Sub End Module
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|