Finally I got an idea, how to store references to a value type, without the need of a Thread. This method would/could use ventilator's suggested idea, of keeping an array for all variables that should be updated, in/because of these panel functions and update them at the beginning/end of a frame...
The downside is, that the code for the user to enter isn't that beautiful (two lambdas, if the panel function would read AND write into the variable)...
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class ReferenceStorage
    {
        public delegate double getValue();
        public delegate void setValue(double value);
        public getValue getValueLambda;
        public setValue setValueLambda;

        public ReferenceStorage(getValue getValueLambda, setValue setValueLambda)
        {
            this.getValueLambda = getValueLambda;
            this.setValueLambda = setValueLambda;
        }


    }

    class Program
    {
        /* this method should depict the engine, changing/reading through the reference */
        static void backgroundFunction(ReferenceStorage.getValue getValue, ReferenceStorage.setValue setValue)
        {
            /* 
             * if a permanent reference to that variable would be needed,
             * create a Reference Storage, to keep the two Lambda expressions
             * 
             * code :
             * 
             * ReferenceStorage newStorage = new ReferenceStorage(getValue, setValue);
             */


            while (true)
            {
                setValue(getValue() + 1);
                Console.WriteLine(getValue() + " increased, using lambda expression");

                System.Threading.Thread.Sleep(1500);
            }

        }

        /* a method that would be called from the user */
        static void dummyWrapperFunction(ReferenceStorage.getValue getValue, ReferenceStorage.setValue setValue)
        {
            System.Threading.Thread t = new System.Threading.Thread(
                () => { backgroundFunction(getValue, setValue); }
            );
            t.Start();
        }



        static void Main(string[] args)
        {
            double dummyValue = 30;

            /* call a dummy wrapper function and pass a 'reference' to the value type dummyValue 
             *
             * THIS is the code that user would have to enter, if the panel function would read AND write into the variable
             */
            dummyWrapperFunction(
                () => { return dummyValue; },
                (double newDummyValue) => { dummyValue = newDummyValue; }
            );

            while (true)
            {
                dummyValue += 1;
                Console.WriteLine(dummyValue + " increaesd, through directly increasing the variable");

                System.Threading.Thread.Sleep(1500);
            }
        }
    }
}



This could/would most likely be preferable over the two other options I mentioned, although it's not that easy for the user to use....

edit:
I'm currently always referring to double as the new variable type that could replace Var, but what I'm asking myself is, wouldn't a float suffice, as the value range of Var is already way smaller than float ?
pros for float in my opinion would be, a double isn't really needed and float should be faster in general than double I think
cons for float would be, that the usage of float is ugly to say the least... for example, the following statement is not allowed :
Code:
float bla = 30.2;


it has to be :
Code:
float bla = 30.2f;



Last edited by Stromausfall; 04/01/10 08:13.

get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread