Exemple #1
0
		public static uint Add (uint interval, TimeoutHandler hndlr)
		{
			TimeoutProxy p = new TimeoutProxy (hndlr);

			p.ID = g_timeout_add (interval, (TimeoutHandlerInternal) p.proxy_handler, IntPtr.Zero);
			Source.AddSourceHandler (p.ID, p);

			return p.ID;
		}
Exemple #2
0
		public static uint Add (uint interval, TimeoutHandler hndlr, Priority priority)
		{
			TimeoutProxy p = new TimeoutProxy (hndlr);

			p.ID = g_timeout_add_full ((int)priority, interval, (TimeoutHandlerInternal) p.proxy_handler, IntPtr.Zero, null);
			Source.AddSourceHandler (p.ID, p);

			return p.ID;
		}
Exemple #3
0
        public static uint AddSeconds(uint interval, TimeoutHandler hndlr)
        {
            TimeoutProxy p = new TimeoutProxy (hndlr);

            p.ID = g_timeout_add_seconds (interval, (TimeoutHandlerInternal) p.proxy_handler, IntPtr.Zero);
            lock (Source.source_handlers)
                Source.source_handlers [p.ID] = p;

            return p.ID;
        }
Exemple #4
0
        /// <summary>
        /// Construct new timer.
        /// </summary>
        /// <param name="timeoutHandler">timeout handler</param>
        /// <param name="cancelHandler">timer cancel handler, optional</param>
        public Timer(TimeoutHandler timeoutHandler,
                     TimerCancelHandler cancelHandler = null)
        {
            _timeoutHandler = timeoutHandler;
            _cancelHandler = cancelHandler;

            _nativeTimeoutDeleg = _OnTimeout;
            _nativeCancelDeleg = _OnCancel;
            _nativeTimer = LLBCNative.csllbc_Timer_Create(_nativeTimeoutDeleg, _nativeCancelDeleg);
        }
Exemple #5
0
        public static uint Add(uint interval, TimeoutHandler hndlr, Priority priority)
        {
            TimeoutProxy p = new TimeoutProxy (hndlr);

            p.ID = g_timeout_add_full ((int)priority, interval, (TimeoutHandlerInternal) p.proxy_handler, IntPtr.Zero, null);
            lock (Source.source_handlers)
                Source.source_handlers [p.ID] = p;

            return p.ID;
        }
Exemple #6
0
        public static uint Add(uint interval, TimeoutHandler handler)
        {
            var proxy = new TimeoutProxy (handler);
            uint code = clutter_threads_add_timeout (interval, (TimeoutHandlerInternal)proxy.proxy_handler, IntPtr.Zero);

            lock (Source.source_handlers) {
                Source.source_handlers[code] = proxy;
            }

            return code;
        }
        public long Add(TimeSpan timeout, TimeoutHandler handler, object state)
        {
            CheckDisposed();
            if (timeout == TimeSpan.Zero)
                timeout = TimeSpan.FromMilliseconds(1);
            var item = new TimeoutItem
                {Id = Interlocked.Increment(ref _timeoutIds), Timeout = timeout, Handler = handler, State = state};
            item.Timer = new Timer(TimerCallback, item, timeout, timeout);

            Add(ref item);

            return item.Id;
        }
Exemple #8
0
        public AsyncHttpRequest(
            IHttpServer pServer, OSHttpRequest pRequest, OSHttpResponse pResponse, 
            UUID pAgentID,  TimeoutHandler pTimeoutHandler, int pTimeout)
        {
            m_lock = new Object();
            m_requestCompleted = false;

            m_httpServer = pServer;
            m_requestID = UUID.Random();
            m_agentID = pAgentID;
            m_httpRequest = pRequest;
            m_httpResponse = pResponse;
            m_requestData = new Hashtable();

            Hashtable headervals = new Hashtable();
            string[] querystringkeys = HttpRequest.QueryString.AllKeys;
            string[] rHeaders = HttpRequest.Headers.AllKeys;

            string requestBody;
            using (StreamReader reader = new StreamReader(pRequest.InputStream, Encoding.UTF8))
            {
                requestBody = reader.ReadToEnd();
            }

            RequestData.Add("body", requestBody);
            RequestData.Add("uri", HttpRequest.RawUrl);
            RequestData.Add("content-type", HttpRequest.ContentType);
            RequestData.Add("http-method", HttpRequest.HttpMethod);

            foreach (string queryname in querystringkeys)
                RequestData.Add(queryname, HttpRequest.QueryString[queryname]);

            foreach (string headername in rHeaders)
                headervals[headername] = HttpRequest.Headers[headername];

            RequestData.Add("headers", headervals);
            RequestData.Add("querystringkeys", querystringkeys);

            // Timeout
            m_Timeout = pTimeoutHandler;
            m_timeout = pTimeout;
            m_requestTime = Util.GetLongTickCount();
            TimedOut = false;

            if (m_timeout != 0)
            {
                m_requestTimer = new Timer(TimerHandler, null, m_timeout, -1);
            }
        }
Exemple #9
0
        public object AddTimeout(uint timeout, TimeoutHandler handler)
        {
            IntPtr source = g_timeout_source_new(timeout);

            if(source == IntPtr.Zero)
                throw new ArgumentException("timeout");

            uint[] id_object = new uint[1];
            object[] args = new object[2];
            args[0] = handler;
            args[1] = id_object;

            IntPtr data = (IntPtr)GCHandle.Alloc(args);
            DestroyNotify notify = DestroyHelper.NotifyHandler;
            g_source_set_callback(source, TimeoutHandler, data, notify);

            uint id = g_source_attach(source, Context);
            g_source_unref(source);
            id_object[0] = id;

            return (object)id_object;
        }
Exemple #10
0
 public TimeoutProxy(TimeoutHandler real)
 {
     real_handler = real;
     proxy_handler = new TimeoutHandlerInternal (Handler);
 }
 public uint Add(uint timeoutMs, TimeoutHandler handler)
 {
     return(Add(timeoutMs, handler, null));
 }
 public uint Add(TimeSpan timeout, TimeoutHandler handler)
 {
     return(Add(timeout, handler, null));
 }
Exemple #13
0
 public static Timeout OnComplete(this Timeout watch, TimeoutHandler handler)
 {
     watch.Complete += handler;
     return watch;
 }
 public long Add(uint timeoutMs, TimeoutHandler handler, object state)
 {
     return Add(TimeSpan.FromMilliseconds(timeoutMs), handler, state);
 }
 public long Add(uint timeoutMs, TimeoutHandler handler)
 {
     return Add(timeoutMs, handler, null);
 }
Exemple #16
0
 protected uint RunTimeout(uint milliseconds, TimeoutHandler handler)
 {
     return(GLib.Timeout.Add(milliseconds, delegate { return handler(); }));
 }
Exemple #17
0
		public static bool Remove (TimeoutHandler hndlr)
		{
			bool result = false;
			ArrayList keys = new ArrayList ();

			lock (Source.source_handlers) {
				foreach (uint code in Source.source_handlers.Keys) {
					TimeoutProxy p = Source.source_handlers [code] as TimeoutProxy;
				
					if (p != null && p.real_handler == hndlr) {
						keys.Add (code);
						result = g_source_remove_by_funcs_user_data (p.proxy_handler, IntPtr.Zero);
					}
				}

				foreach (object key in keys)
					Source.source_handlers.Remove (key);
			}

			return result;
		}
Exemple #18
0
 protected uint RunTimeout (uint milliseconds, TimeoutHandler handler)
 {
     return GLib.Timeout.Add (milliseconds, delegate { return handler (); });
 }
 public PulseBar(ProgressBar ProgressTarget)
 {
     handler = new TimeoutHandler(Timer_Tick);
     PrBar = ProgressTarget;
     Step = 0.05;
 }
Exemple #20
0
 public static object AddTimeout(uint timeout, TimeoutHandler handler)
 {
     return Native.Factory.GetLoop().AddTimeout(timeout, handler);
 }
Exemple #21
0
        public static uint RunTimeout (uint milliseconds, TimeoutHandler handler)
        {
            if (timeout_handler == null) {
                throw new NotImplementedException ("The application client must provide a TimeoutImplementationHandler");
            }

            return timeout_handler (milliseconds, handler);
        }
 public MyTimer(TimeoutHandler Tick_Handler)
 {
     handler = Tick_Handler;
     Time = 1000;
 }
Exemple #23
0
 public static uint AddSeconds(this Timeout timeout, uint interval, TimeoutHandler hndlr)
 {
     return Timeout.Add (1000 * interval, hndlr);
 }
Exemple #24
0
        public static bool Remove(TimeoutHandler hndlr)
        {
            bool result = false;
            List<uint> keys = new List<uint> ();

            lock (Source.source_handlers) {
                foreach (uint code in Source.source_handlers.Keys) {
                    TimeoutProxy p = Source.source_handlers [code] as TimeoutProxy;

                    if (p != null && p.real_handler == hndlr) {
                        keys.Add (code);
                        result = g_source_remove (code);
                    }
                }

                foreach (object key in keys)
                    Source.source_handlers.Remove (key);
            }

            return result;
        }
 public long Add(TimeSpan timeout, TimeoutHandler handler)
 {
     return Add(timeout, handler, null);
 }
Exemple #26
0
		public static bool Remove (TimeoutHandler hndlr)
		{
			return Source.RemoveSourceHandler (hndlr);
		}
 public MyTimer(TimeoutHandler Tick_Handler)
 {
     handler = Tick_Handler;
     Time    = 1000;
 }
Exemple #28
0
        /// <summary>
        /// Schedule timer, same with Non-Static Schedule(DateTime, double) method.
        /// </summary>
        /// <param name="timeoutHandler">Timeout handler</param>
        /// <param name="firstTimeoutTime">first timeout time</param>
        /// <param name="period">period, in seconds</param>
        /// <param name="cancelHandler">timer cancel handler</param>
        /// <returns>new timer object</returns>
        public static Timer Schedule(TimeoutHandler timeoutHandler,
                                     DateTime firstTimeoutTime,
                                     double period = 0.0,
                                     TimerCancelHandler cancelHandler = null)
        {
            Timer timer = new Timer(timeoutHandler, cancelHandler);
            timer.Schedule(firstTimeoutTime, period);

            return timer;
        }