public void Start()
        {
            if (!loadingError)
            {
                startupError = false;
                try
                {
                    callbackHandler = new HPMCallbackHandler(eventWindow);
                    callbackHandler.ProjectCreateCompleted += new System.EventHandler <EventArgs>(OnProjectCreateCompleted);
                    SessionManager.Initialize(sdkUser, sdkUserPwd, server, portNumber, databaseName);

                    if (SessionManager.Instance.Connect(callbackHandler, callbackSemaphore))
                    {
                        //TODO: The hooking up of the event handlers should be pushed down into a registration function in CallbackHandler
                        foreach (AbstractBehavior b in behaviors)
                        {
                            callbackHandler.TaskChange += new System.EventHandler <TaskChangeEventArgs>(b.OnTaskChange);
                            callbackHandler.TaskChangeCustomColumnData += new System.EventHandler <TaskChangeCustomColumnDataEventArgs>(b.OnTaskChangeCustomColumnData);
                            callbackHandler.TaskCreate                 += new System.EventHandler <TaskCreateEventArgs>(b.OnTaskCreate);
                            callbackHandler.TaskMove                   += new System.EventHandler <TaskMoveEventArgs>(b.OnTaskMove);
                            callbackHandler.DataHistoryReceived        += new System.EventHandler <DataHistoryReceivedEventArgs>(b.OnDataHistoryReceived);
                            callbackHandler.ProjectCreate              += new System.EventHandler <ProjectCreateEventArgs>(b.OnProjectCreate);
                            callbackHandler.TaskDelete                 += new System.EventHandler <TaskDeleteEventArgs>(b.OnTaskDelete);
                            callbackHandler.BeginProcessBufferedEvents += new System.EventHandler <EventArgs>(b.OnBeginProcessBufferedEvents);
                            callbackHandler.EndProcessBufferedEvents   += new System.EventHandler <EventArgs>(b.OnEndProcessBufferedEvents);
                            InitializeBehaviors();
                        }

                        startSemaphore.Release();
                        logger.Information("Jean connected to " + server + ": " + portNumber + " (" + databaseName + ")");
                    }
                    else
                    {
                        startupError = true;
                        logger.Warning("Could not connect to the Hansoft server with the specified connection parameters.");
                    }
                }
                catch (Exception e)
                {
                    startupError = true;
                    logger.Exception("Jean could not be started.", e);
                }
            }
            else
            {
                logger.Warning("It was not possible to start Jean due to a previous error when loading the service");
            }
        }
 public void Stop()
 {
     if (!loadingError)
     {
         if (callbackHandler != null)
         {
             callbackHandler.Dispose();
         }
         callbackHandler = null;
         if (SessionManager.Instance.Connected)
         {
             SessionManager.Instance.CloseSession();
         }
         stopped = true;
         if (!startupError)
         {
             callbackSemaphore.Release();
         }
         logger.Information("Jean for Hansoft was stopped");
     }
 }