Inheritance: IDisposable
Exemple #1
0
        /// <summary>
        /// SharmIpc constructor
        /// </summary>
        /// <param name="uniqueHandlerName">Must be unique in OS scope (can be PID [ID of the process] + other identifications)</param>
        /// <param name="remoteCallHandler">Callback routine for the remote partner requests. AsyncAnswerOnRemoteCall must be used for answer</param>
        /// <param name="bufferCapacity">bigger buffer sends larger datablocks faster. Default value is 50000</param>
        /// <param name="maxQueueSizeInBytes">If remote partner is temporary not available, messages are accumulated in the sending buffer. This value sets the upper threshold of the buffer in bytes.</param>
        public SharmIpc(string uniqueHandlerName, Action<ulong, byte[]> remoteCallHandler, long bufferCapacity = 50000, int maxQueueSizeInBytes = 20000000)
        {
            if (remoteCallHandler == null)
                throw new Exception("tiesky.com.SharmIpc: remoteCallHandler can't be null");

            this.AsyncRemoteCallHandler = remoteCallHandler;
            sm = new SharedMemory(uniqueHandlerName, this.InternalDataArrived, bufferCapacity, maxQueueSizeInBytes);
        }
Exemple #2
0
        /// <summary>
        /// SharmIpc constructor
        /// </summary>
        /// <param name="uniqueHandlerName">Must be unique in OS scope (can be PID [ID of the process] + other identifications)</param>
        /// <param name="remoteCallHandler">Response routine for the remote partner requests</param>
        /// <param name="bufferCapacity">bigger buffer sends larger datablocks faster. Default value is 50000</param>
        /// <param name="maxQueueSizeInBytes">If remote partner is temporary not available, messages are accumulated in the sending buffer. This value sets the upper threshold of the buffer in bytes.</param>
        /// <param name="ExternalExceptionHandler">External exception handler can be supplied, will be returned Description from SharmIPC, like class.method name and handeled exception</param>
        public SharmIpc(string uniqueHandlerName, Func<byte[], Tuple<bool, byte[]>> remoteCallHandler, long bufferCapacity = 50000, int maxQueueSizeInBytes = 20000000, Action<string, System.Exception> ExternalExceptionHandler = null)
        {
            if (remoteCallHandler == null)
                throw new Exception("tiesky.com.SharmIpc: remoteCallHandler can't be null");

            this.remoteCallHandler = remoteCallHandler;
            this.ExternalExceptionHandler = ExternalExceptionHandler;
            sm = new SharedMemory(uniqueHandlerName, this, bufferCapacity, maxQueueSizeInBytes);
        }
Exemple #3
0
        public ReaderWriterHandler(SharedMemory sm, Action <eMsgType, ulong, byte[]> DataArrived)
        {
            this.sm          = sm;
            this.DataArrived = DataArrived;
            this.bufferLenS  = Convert.ToInt32(sm.bufferCapacity) - protocolLen;

            this.InitWriter();
            this.InitReader();

            //SendProcedure1();
        }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        public void Dispose()
        {
            try
            {
                if (sm != null)
                {
                    sm.Dispose();
                    sm = null;
                }
            }
            catch
            {}

            try
            {
                ResponseCrate rc=null;
                foreach (var el in df.ToList())
                {
                    if (df.TryRemove(el.Key, out rc))
                    {
                        if (rc.mre != null)
                        {
                            rc.IsRespOk = false;
                            rc.mre.Set();
                            rc.mre.Dispose();
                            rc.mre = null;
                        }
                    }
                    
                }
            }
            catch
            {
            }
         
        }
        public ReaderWriterHandler(SharedMemory sm)
        {
            this.sm = sm;
            //this.DataArrived = DataArrived;
            this.bufferLenS = Convert.ToInt32(sm.bufferCapacity) - protocolLen;

            this.InitWriter();
            this.InitReader();

            //SendProcedure1();
        }
        public ReaderWriterHandler(SharedMemory sm, Action<eMsgType, ulong, byte[]> DataArrived)
        {
            this.sm = sm;
            this.DataArrived = DataArrived;
            this.bufferLenS = Convert.ToInt32(sm.bufferCapacity) - protocolLen;

            this.InitWriter();
            this.InitReader();

            //SendProcedure1();
        }