By Philippe Bonneau on
2/2/2016 1:49 PM
Some days ago, I talked about the possibility to use the Sophis.Core.Data, Sophis.Event.Core and Sophis.Event.Risque assemblies, in order to listen to specific events for toolkit columns performance optimizations. I've tried to use the same mechanism in a batch, using the following code :
class
Program
{
static
void
ProcessEvent(Sophis.Event.IEvent myEvent,
ref
bool
bProcess)
{
}
static
void
Main(
string
[] args)
{
CSMApi _api =
new
CSMApi();
try
{
_api.Initialise();
}
catch
(Exception e)
{
return
;
}
Sophis.Event.SophisEventHandler _handler =
new
Sophis.Event.SophisEventHandler(ProcessEvent);
Sophis.Event.SophisEventManager.Instance.AddHandler(_handler, Sophis.Event.Thread.MainProcess, Sophis.Event.Layer.Model);
bool
_stop =
false
;
while
(!_stop)
{
Sophis.Event.SophisEventManager.Instance.Dispatch();
System.Threading.Thread.Sleep(500);
}
Unfortunately, this code does not work as is. Putting a break point in the ProcessEvents method shows that it is never called, even if messages are received and processed. The goal of this post is to explain how it works and what it is missing.