Exemplo n.º 1
0
 /// <summary>
 /// 定时获取图片生成 GIF 文件
 /// </summary>
 /// <param name="filename">输出 GIF 文件名</param>
 /// <param name="getBitmap">获取图片委托</param>
 /// <param name="width">图片最大高度</param>
 /// <param name="height">图片最大宽度</param>
 /// <param name="interval">截屏定时毫秒数</param>
 /// <param name="maxPixel">最大色彩深度</param>
 /// <param name="isWaitFinally">释放资源是否等待 GIF 文件处理结束</param>
 public TimerWriter(string filename, Func <Bitmap> getBitmap, int width, int height, int interval = 40, byte maxPixel = 8, bool isWaitFinally = true)
 {
     if (getBitmap == null)
     {
         throw new ArgumentNullException();
     }
     if (width <= 0)
     {
         throw new IndexOutOfRangeException("width");
     }
     if (height <= 0)
     {
         throw new IndexOutOfRangeException("height");
     }
     this.getBitmap = getBitmap;
     this.maxPixel  = (byte)(maxPixel - 2) < 8 ? maxPixel : (byte)8;
     bitmapQueue    = new BitmapInfo.YieldQueue(new BitmapInfo());
     gif            = new FileWriter(filename, (short)width, (short)height);
     this.interval  = interval < 40 ? 40 : interval;
     bitmapWait.Set(0);
     if (this.isWaitFinally = isWaitFinally)
     {
         finallyWait.Set(0);
     }
     timer = new System.Threading.Timer(onTimer, this, interval, interval);
     onTimer(null);
     AutoCSer.Threading.ThreadPool.TinyBackground.Start(write);
 }
Exemplo n.º 2
0
        /// <summary>
        /// TCP 服务客户端
        /// </summary>
        /// <param name="attribute">TCP服务调用配置</param>
        /// <param name="log">日志接口</param>
        /// <param name="onCustomData">自定义数据包处理</param>
        internal ClientBase(ServerBaseAttribute attribute, ILog log, Action <SubArray <byte> > onCustomData)
            : base(attribute, attribute.GetSendBufferSize, attribute.GetReceiveBufferSize, attribute.ClientSendBufferMaxSize, log)
        {
            OutputSleep         = attribute.GetClientOutputSleep;
            FristTryCreateSleep = Math.Max(attribute.GetClientFirstTryCreateSleep, 10);
            TryCreateSleep      = Math.Max(attribute.GetClientTryCreateSleep, 10);
            SocketWait.Set(0);

            this.onCustomData = onCustomData;
            clientCreator     = new ClientSocketCreator(this);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 日志
 /// </summary>
 /// <param name="table"></param>
 /// <param name="memberIndexs"></param>
 protected Log(Table table, int[] memberIndexs)
 {
     wait.Set(0);
     if ((waitCount = memberIndexs.Length) > 0)
     {
         int maxIndex = memberIndexs.max(0);
         waitMap = new byte[(maxIndex >> 3) + 1];
         foreach (int memberIndex in memberIndexs)
         {
             waitMap[memberIndex >> 3] |= (byte)(1 << (int)(memberIndex & 7));
         }
     }
     waitCount += 3;
     (this.table = table).OnCacheLoaded += cacheLoaded;
 }
Exemplo n.º 4
0
        /// <summary>
        /// TCP 注册服务客户端
        /// </summary>
        /// <param name="serviceName">TCP 注册服务服务名称</param>
        private Client(string serviceName)
        {
#if NoAutoCSer
            throw new Exception();
#else
            //attribute = AutoCSer.config.pub.LoadConfig(new AutoCSer.code.cSharp.tcpServer(), serviceName);
            //attribute.IsIdentityCommand = true;
            //attribute.TcpRegister = null;
            this.serviceName = serviceName;
            createWait.Set(0);
            registerClient = new Server.TcpInternalClient(TcpInternalServer.ServerAttribute.GetConfig(serviceName, typeof(AutoCSer.Net.TcpRegister.Server)));
            //isNewClientErrorLog = true;
            logHandle          = onLog;
            checkSocketVersion = registerClient._TcpClient_.CreateCheckSocketVersion(onNewSocket);
#endif
        }
Exemplo n.º 5
0
 /// <summary>
 /// TCP 服务客户端
 /// </summary>
 /// <param name="attribute">TCP服务调用配置</param>
 /// <param name="log">日志接口</param>
 public ClientBase(attributeType attribute, ILog log)
     : base(attribute, attribute.GetSendBufferSize, attribute.GetReceiveBufferSize, attribute.ClientSendBufferMaxSize, log)
 {
     OutputSleep    = attribute.GetClientOutputSleep;
     TryCreateSleep = Math.Max(attribute.GetClientTryCreateSleep, 10);
     SocketWait.Set(0);
     clientCreator = new ClientSocketCreator <attributeType>(this);
 }
Exemplo n.º 6
0
 public valueType Set(valueType value)
 {
     if (value != null)
     {
         this.value = value;
         wait.Set();
     }
     return(value);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 等待设置数据
 /// </summary>
 /// <param name="value">设置的数据</param>
 public WaitSetValue(valueType value)
 {
     this.value = value;
     wait       = new AutoCSer.Threading.WaitHandle();
     if (value == null)
     {
         wait.Set(0);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 异步等待
 /// </summary>
 public Awaiter()
 {
     waitHandle.Set(0);
 }
Exemplo n.º 9
0
 /// <summary>
 /// 成员扩展缓存初始化依赖类型加载
 /// </summary>
 /// <param name="cacheTypes">成员扩展缓存初始化依赖类型集合</param>
 private MemberCacheWait(HashSet <Type> cacheTypes)
 {
     wait.Set(0);
     set(cacheTypes);
 }