After working a bit on this problem, i found a workaround :
The problem is that you can only use CallImmediateCondition() from MMF thread, so I stored every event that should trigger such a callback in a container, and asked MMF to Always CallFunction("TriggerConditions",""). This way, all the ImmediateConditions will be called from inside MMF thread. Here is a simple example :
Code:
static class Global {
//ATTRIBUTES
private static Mutex MutexMMF=new Mutex();
private static ArrayList Conditions=new ArrayList();
public static void AddCondition(string nom, string[] param) {
MutexMMF.WaitOne();
Conditions.Add(new MMFCondition(nom, param));
MutexMMF.ReleaseMutex();
}//Adds a MMFCondition inside Conditions
public static void TriggerConditions() {
MutexMMF.WaitOne();
foreach(MMFCondition c in Conditions) {
MMFInterface.Conditions.CallImmediateCondition(c.nom, c.param);
//Console.WriteLine(c.nom+" : "+c.param[0]+"||"+c.param[1]);
}
Conditions.Clear();
MutexMMF.ReleaseMutex();
}//Triggers all the MMFImmediateConditions Stored in Conditions
}
class MMFCondition {
//attributes
private string _nom;
private string[] _param;
//properties
public string nom {
get { return _nom; }
}//public, read only
public string[] param {
get { return _param; }
}//public, read only
//constructor
public MMFCondition(string nom, string[] param) {
_param=new string[param.Length];
_nom=nom;
param.CopyTo(_param, 0);
}
}//Our condition class to trigger an MMFInterface.CallImmediateCondition
This seems to work perfectly here, without any list object to retrieve the params