0 Replies Latest reply on Mar 1, 2016 8:58 AM by Matt Sickler

    Handle is not initialized on shutdown of C# application

    Matt Sickler New Member

      I’m having an issue during shutdown of a C# application.


      Description: The process was terminated due to an unhandled exception.

      Exception Info: System.InvalidOperationException

      Stack:

         at System.Runtime.InteropServices.GCHandle.Free()

         at com.latencybusters.lbm.LBMReceiver.Dispose(Boolean)

         at com.latencybusters.lbm.LBMReceiver.Dispose()



      I have ensured that I properly close any open request/messages. Here is some additional code to help explain the lifecycle:

       

      //init

      var lbmContextAttributes = new LBMContextAttributes("");

      1. lbmContextAttributes.setValue("fd_management_type", "wincompport");
      2. this.LbmContext = new LBMContext(lbmContextAttributes);

       

      recycler = new LBMObjectRecycler();

       

      //init publish topic

      var pubAttributes = new LBMSourceAttributes("", Name);

      1. pubAttributes.setObjectRecycler(recycler, null);

      lbmTopic = new LBMTopic(this.LbmContext, this.Name, pubAttributes);

      lbmPubSource = new LBMSource(this.LbmContext, lbmTopic);

      1. Thread.Sleep(500);

       

      //init subsciption topic

      var subAttributes = new LBMReceiverAttributes("", Name);

      1. subAttributes.setObjectRecycler(recycler, null);

      lbmSubTopic = this.LbmContext.lookupTopic(this.Name, subAttributes);

       

      //init receiver

      If (wildcard) {

      LBMWildcardReceiver receiver = new LBMWildcardReceiver(this.LbmContext, pattern, null, null, OnReceive, null);

      }

      else {

      LBMReceiver receiver = new LBMReceiver(this.LbmContext, lbmSubTopic, OnReceive, null, null);

      }

       

      // publish a bit, receive a bit, etc

      //…

      // finally later when I want to shutdown

       

      foreach (var request in requests) {

      1. request.close();

      }

      foreach (var msg in promotedMessage) {

      1. msg.dispose();

      }

      if (lbmPubSource != null && !lbmPubSource.isClosed()) {

      lbmPubSource.close();

      lbmPubSource = null;

      }

      if (this.LBMReceiver != null) {

      1. this.LBMReceiver.removeReceiver(OnReceive);

      this.LBMReceiver.close();

      this.LBMReceiver = null;

      }

      if (this.LBMWildcardReceiver != null) {

      1. this.LBMReceiver.removeReceiver(OnReceive);

      this.LBMWildcardReceiver.close();

      this.LBMWildcardReceiver = null;

      }

      1. recycler.close();