public ExchangeDataDispatcher(ExchangeCommonDataSource parDataSource)
 {
     myDataSource = parDataSource;
     myDataSource.HandleDataReceived +=
         new EventHandler(HandleDataReceived);
     DispatcherInitialization();
 }
Пример #2
0
 // this factory method looks up whether the source with the passed
 // Guid already exists; if it does, it returns that, otherwise it
 // creates the data source and adds it to the lookup table
 public static ExchangeCommonDataSource GetConnection(
     Guid parSourceGuid, string parUsername, long parBigNumber
     )
 {
     // there are many issues involved with thread safety, I do not
     // guarantee that I got it right here, it's to show the idea. :)
     // here I'm just providing some thread safety; by placing a lock
     // around the sources to prevent two separate calls to a factory
     // method from each creating a source with the same Guid.
     lock (allSources)
     {
         ExchangeCommonDataSource RetVal;
         allSources.TryGetValue(parSourceGuid, out RetVal);
         if (RetVal == null)
         {
             // using member initializer, you can do this to limit the
             // number of constructors; here we only need the one
             RetVal = new ExchangeCommonDataSource(parSourceGuid)
             {
                 Username = parUsername, BigNumber = parBigNumber
             };
             allSources.Add(parSourceGuid, RetVal);
         }
         return(RetVal);
     }
 }
Пример #3
0
 // see http://www.switchonthecode.com/tutorials/dotnet-35-adds-named-pipes-support
 // for some info on named pipes in .NET
 public ExchangeDataLocalMachineDispatcher(
     ExchangeCommonDataSource parDataSource,
     NamedPipeServerStream ServerPipe
     ) :
     base(parDataSource)
 {
     myPipe = ServerPipe;
     // do any extra initialization, etc. here, negotiation for instance
     StartPipeThread();
 }