I am writing an application in Visual Studio 2013 using C#
I have some live values that I get from Kinect and I process those values and save them in a floating point.
there are about 8 values
I need to print these values out on my window how do I go about that??
If you just need to Display your constantly changing floating point number on your Window, You can use Label
. But as values changing frequently this may cause GUI to hang. To prevent this I have an extension Class
public static class CrossThreadExtensions
{
public static void PerformSafely(this Control target, Action action)
{
if (target.InvokeRequired)
{
target.Invoke(action);
}
else
{
action();
}
}
public static void PerformSafely<T1>(this Control target, Action<T1> action, T1 parameter)
{
if (target.InvokeRequired)
{
target.Invoke(action, parameter);
}
else
{
action(parameter);
}
}
public static void PerformSafely<T1, T2>(this Control target, Action<T1, T2> action, T1 p1, T2 p2)
{
if (target.InvokeRequired)
{
target.Invoke(action, p1, p2);
}
else
{
action(p1, p2);
}
}
}
And use in this way
On value change event:
Thread erThread = new Thread(delegate()
{
label1.PerformSafely(() => label1.Text = _YourFloatingPointValue.ToString());
});
erThread.Start();
erThread.IsBackground = true;