Ejemplo n.º 1
0
        public void Set(string key, object value, TimeSpan expires, CacheItemCallback callback)
        {
            CacheItem item = SetInternal(key, value);

            AppHost.AddTimeout(expires, RepeatBehavior.Single, item, HandleExpires);

            if (callback != null)
            {
                callback(key, value);
            }
        }
Ejemplo n.º 2
0
        public void AddTimeout_TimeoutAddedBeforeStart_TimeoutIsFiredAfterStart()
        {
            TimeSpan t = TimeSpan.FromMilliseconds(1);

            bool timeout_called = false;

            AppHost.AddTimeout(t, RepeatBehavior.Single, null, (app, data) => timeout_called = true);

            ThreadPool.QueueUserWorkItem(cb => AppHost.Start(new ManosAppStub()));
            Thread.Sleep(TimeSpan.FromSeconds(5));
            AppHost.Stop();

            Assert.IsTrue(timeout_called);
        }
Ejemplo n.º 3
0
        public void SetServerUser(string user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            PlatformID pid = System.Environment.OSVersion.Platform;

            if (pid != PlatformID.Unix /* && pid != PlatformID.MacOSX */)
            {
                // TODO: Not sure if this works on OSX yet.

                //
                // Throw an exception here, we don't want to silently fail
                // otherwise people might be unknowingly running as root
                //

                throw new InvalidOperationException("User can not be set on Windows platforms.");
            }

            AppHost.AddTimeout(TimeSpan.Zero, RepeatBehavior.Single, user, DoSetUser);
        }