Changeset 13547


Ignore:
Timestamp:
01/18/16 15:28:29 (5 years ago)
Author:
thasling
Message:

Added Dispose() to MessageHandler and WCF service host

Location:
branches/thasling/DistributedGA
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs

    r13541 r13547  
    2424    private ConcurrentQueue<SolutionInfo> writeQueue;
    2525    private ConcurrentQueue<SolutionInfo> readQueue;
    26     private bool collectingInFirstQueue = true; //currently first queue is filled with recieved populations
    2726
    2827    //uses IMessageService for recieving population from one peer at once
     
    5554      } catch (Exception ex) {
    5655        AddError("PeerNetworkMessageHandler.Init", ex);
     56      }
     57    }
     58
     59    public void Dispose() {
     60      try {
     61        host.Dispose();
     62      } catch (Exception ex) {
     63        AddError("PeerNetworkMessageHandler.Dispose", ex);
    5764      }
    5865    }
     
    144151      }
    145152    }
     153
    146154  }
    147155}
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageService.cs

    r13541 r13547  
    4242    }
    4343
     44    public void Dispose() {
     45      _ResetEvent.Set();
     46    }
     47
    4448    private int FreeTcpPort() {
    4549      TcpListener l = new TcpListener(IPAddress.Loopback, 0);
     
    5559      }
    5660    }
    57 
    5861  }
    5962}
  • branches/thasling/DistributedGA/DistributedGA.Core/Interface/IMessageHandler.cs

    r13524 r13547  
    1 using DistributedGA.Core.Domain;
    2 using System;
    3 using System.Collections.Generic;
    4 using System.Linq;
    5 using System.Text;
    6 using System.Threading.Tasks;
     1using System.Collections.Generic;
     2using DistributedGA.Core.Domain;
    73
    8 namespace DistributedGA.Core.Interface
    9 {
    10     public interface IMessageHandler
    11     {
    12         void Init(); //Registers at contract-server
     4namespace DistributedGA.Core.Interface {
     5  public interface IMessageHandler {
     6    void Init(); //Registers at contract-server
    137
    14         void PublishMigrationInfo(SolutionInfo[] population);
     8    void PublishMigrationInfo(SolutionInfo[] population);
    159
    16         SolutionInfo[] GetMigrationInfo();
     10    SolutionInfo[] GetMigrationInfo();
    1711
    18         PeerInfo GetPeerInfo();
     12    PeerInfo GetPeerInfo();
    1913
    20         List<PeerInfo> GetCurrentNetwork();
    21     }
     14    List<PeerInfo> GetCurrentNetwork();
     15
     16    void Dispose();
     17  }
    2218}
  • branches/thasling/DistributedGA/DistributedGA.Core/Interface/IMessageService.cs

    r13524 r13547  
    1 using DistributedGA.Core.Domain;
    2 using System;
    3 using System.Collections.Generic;
    4 using System.Linq;
    5 using System.Text;
    6 using System.Threading.Tasks;
     1using System;
     2using DistributedGA.Core.Domain;
    73
    8 namespace DistributedGA.Core.Interface
    9 {
    10     public interface IMessageService
    11     {
    12         /// <summary>
    13         /// Initializes a WCF service and host it with another thread
    14         /// </summary>
    15         /// <param name="ip">current external ip address</param>
    16         /// <returns>The port, on which the service was successfully hosted</returns>
    17         int Init(string ip);
     4namespace DistributedGA.Core.Interface {
     5  public interface IMessageService {
     6    /// <summary>
     7    /// Initializes a WCF service and host it with another thread
     8    /// </summary>
     9    /// <param name="ip">current external ip address</param>
     10    /// <returns>The port, on which the service was successfully hosted</returns>
     11    int Init(string ip);
    1812
    19         event EventHandler<MessageRecieveEventArgs> OnPopulationRecieved;
    20     }
     13    void Dispose();
     14
     15    event EventHandler<MessageRecieveEventArgs> OnPopulationRecieved;
     16  }
    2117}
Note: See TracChangeset for help on using the changeset viewer.