.NET API and C# PeachtreeSession events don't seem to be triggering.

I'm attempting to implement these events, but they don't seem to be triggered when I close either a company, or the Sage application itself.

My code notifies me that the event handlers are being added, but the handlers never get called.

private static void addEventHandlers(PeachtreeSession session)
        {
            Console.WriteLine("Adding Event Handlers");
            session.CompanyLogoutPending += new LogoutEventHandler(LogoutRequestedEvent);
            session.CompanyClosing += new ClosingEventHandler(CompanyClosingEvent);
            session.CompanyClosed += new ClosedEventHandler(CompanyClosedEvent);
        }
 
        static void LogoutRequestedEvent(object sender, LogoutEventArgs e)
        {
            Console.WriteLine("Logout requested." + e.Company.CompanyIdentifier.CompanyName);
        }
 
        static void CompanyClosingEvent(object sender, CompanyClosingEventArgs e)
        {
            Console.WriteLine("Company Closing: " + e.Company.CompanyIdentifier.CompanyName);
        }
 
        static void CompanyClosedEvent(object sender, CompanyClosedEventArgs e)
        {
            Console.WriteLine("Company Closed: " + e.Company.CompanyIdentifier.CompanyName);
        }

.

  • 0
    I'm a VB.NET user, so your constructs are going to be different. Did you actually 'add' the handler pointing to the address you are indicating? Similar to:

    AddHandler Me.grdExceptions.Model.QueryCellInfo, AddressOf ModelQueryCellInfo
  • 0 in reply to cartspan
    Yes, that's what these lines are doing:

    session.CompanyLogoutPending += new LogoutEventHandler(LogoutRequestedEvent);
    session.CompanyClosing += new ClosingEventHandler(CompanyClosingEvent);
    session.CompanyClosed += new ClosedEventHandler(CompanyClosedEvent);

    Then the three methods below them are where the events will actually be handled.