public bool WaitProc(long timeOutSec)
        {
            timeOut = timeOutSec;
            timeOutDoProc.BeginInvoke(null, null, null);
            bool flag = doEvent.WaitOne((int)timeOut * 1000, false);

            if (!flag)
            {
                if (userDefineProc != null)
                {
                    userDefineProc(null);
                }
            }
            Dispose();
            return(flag);
        }
Exemple #2
0
        /// <summary>
        /// Send to queue pool
        /// </summary>
        /// <param name="entityList"></param>
        public static void Send(params AbstractEntity[] entityList)
        {
            string key = "";

            try
            {
                if (entityList == null || entityList.Length == 0)
                {
                    return;
                }
                var groupList = entityList.GroupBy(t => t.GetIdentityId());
                foreach (var g in groupList)
                {
                    var      valueList  = g.ToList();
                    byte[][] keyBytes   = new byte[valueList.Count][];
                    byte[][] valueBytes = new byte[valueList.Count][];
                    string   queueKey   = GetRedisSyncQueueKey(g.Key);
                    byte[]   idBytes    = BufferUtils.GetBytes(g.Key);

                    int index = 0;
                    foreach (var entity in valueList)
                    {
                        key             = string.Format("{0}_{1}", RedisConnectionPool.EncodeTypeName(entity.GetType().FullName), entity.GetKeyCode());
                        keyBytes[index] = RedisConnectionPool.ToByteKey(key);
                        byte[] stateBytes = BufferUtils.GetBytes(entity.IsDelete ? 1 : 0);
                        valueBytes[index] = BufferUtils.MergeBytes(
                            BufferUtils.GetBytes(idBytes.Length + stateBytes.Length),
                            idBytes,
                            stateBytes,
                            _serializer.Serialize(entity));
                        index++;
                    }
                    _asyncSendHandle.BeginInvoke(queueKey, keyBytes, valueBytes, null, null);
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("Post changed key:{0} error:{1}", key, ex);
            }
        }
 private void UpdateMailCount(EmailAccountItem item)
 {
     this.eMailModal = (item.DataContext as EMailModal);
     if (this.eMailModal != null)
     {
         System.Action<EmailAccountItem> a = new System.Action<EmailAccountItem>(this.OpenExplorer);
         a.BeginInvoke(item, delegate(System.IAsyncResult ar)
         {
             a.EndInvoke(ar);
             this.Setmail(this.eMailModal);
         }, null);
     }
 }