Ejemplo n.º 1
0
        private void GLRenderer_Initialized(object sender, EventArgs e)
        {
            // Release the GL exclusivity that OpenTK gave us as we aren't going to use it in GTK Thread.
            GraphicsContext.MakeCurrent(null);

            WaitEvent.Set();
        }
Ejemplo n.º 2
0
        public void PutValue(byte sid, bool cmdStatu)
        {
            Sid        = sid;
            CmdSuccess = cmdStatu;

            WaitEvent.Set();
        }
Ejemplo n.º 3
0
 protected virtual void Dispose(bool Disposing)
 {
     if (Disposing)
     {
         WaitEvent.Dispose();
     }
 }
Ejemplo n.º 4
0
        public void Reset()
        {
            Sid = 0;
            if (Data != null)
            {
                Array.Clear(Data, 0, Data.Length);
            }

            Data = null;

            if (FloatData != null)
            {
                Array.Clear(FloatData, 0, FloatData.Length);
            }

            if (Int32Data != null)
            {
                Array.Clear(Int32Data, 0, Int32Data.Length);
            }

            FloatData = null;

            CmdSuccess = false;
            RecType    = RecDataType.error;

            WaitEvent.Reset();
        }
Ejemplo n.º 5
0
 protected override void OnStop()
 {
     Container.Resolve <IParallelOperations>().ExecuteParallel(delegate
     {
         WaitEvent.WaitOne();
         throw new Exception("Test");
     });
 }
Ejemplo n.º 6
0
        public static WaitEvent CreateEmptyEvent(Creature nEnt)
        {
            WaitEvent wEvent = new WaitEvent(nEnt);

            wEvent.CreateTime   = Game.TurnsPassed;
            wEvent.ActivateTime = Game.TurnsPassed + 0;

            return(wEvent);
        }
Ejemplo n.º 7
0
 public static IYield NioRead(this Stream stream, byte[] buffer, int offset, int count)
 {
     var waitEvent = new WaitEvent();
     var thread = Microthread.CurrentMicrothread;
     stream.BeginRead(buffer, offset, count, ar =>
                                                 {
                                                     thread.Result = stream.EndRead(ar);
                                                     ((WaitEvent)ar.AsyncState).Set();
                                                 }, waitEvent);
     return Microthread.Wait(waitEvent);
 }
Ejemplo n.º 8
0
        public static IYield NioWrite(this Stream stream, byte[] buffer, int offset, int count)
        {
            var waitEvent = new WaitEvent();
            stream.BeginWrite(buffer, offset, count, ar =>
                                                         {
                                                             stream.EndWrite(ar);
                                                             ((WaitEvent) ar.AsyncState).Set();
                                                         }, waitEvent);

            return Microthread.Wait(waitEvent);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }

            WaitEvent.Dispose();

            base.Dispose(disposing);
        }
Ejemplo n.º 10
0
        protected override bool OnConfigureEvent(EventConfigure evnt)
        {
            if (NativeWindow == null)
            {
                NativeWindow = RetrieveNativeWindow();

                WaitEvent.Set();
            }

            return(base.OnConfigureEvent(evnt));
        }
Ejemplo n.º 11
0
        public static WaitEvent CreateWaitEvent(Creature nWait)
        {
            WaitEvent wEvent = new WaitEvent(nWait);

            wEvent.CreateTime   = Game.TurnsPassed;
            wEvent.ActivateTime = Game.TurnsPassed + 5;

            nWait.State = Creature.EntityState.BUSY;

            return(wEvent);
        }
Ejemplo n.º 12
0
        public void Exit()
        {
            if (IsStopped)
            {
                return;
            }

            IsStopped = true;
            IsActive  = false;

            using (ScopedGlContext scopedGLContext = new ScopedGlContext(WindowInfo, GraphicsContext))
            {
                _device.DisposeGpu();
            }

            WaitEvent.Set();
        }
Ejemplo n.º 13
0
        private void IntializeOpenGL()
        {
            _nativeWindow = RetrieveNativeWindow();

            Window.EnsureNative();

            _openGLContext = PlatformHelper.CreateOpenGLContext(GetGraphicsMode(), 3, 3, _glLogLevel == GraphicsDebugLevel.None ? OpenGLContextFlags.Compat : OpenGLContextFlags.Compat | OpenGLContextFlags.Debug);
            _openGLContext.Initialize(_nativeWindow);
            _openGLContext.MakeCurrent(_nativeWindow);

            // Release the GL exclusivity that SPB gave us as we aren't going to use it in GTK Thread.
            _openGLContext.MakeCurrent(null);

            WaitEvent.Set();

            _initializedOpenGL = true;
        }
Ejemplo n.º 14
0
        private void SvcCancelSynchronization(AThreadState ThreadState)
        {
            int ThreadHandle = (int)ThreadState.X0;

            KThread Thread = GetThread(ThreadState.Tpidr, ThreadHandle);

            if (Thread == null)
            {
                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{ThreadHandle:x8}!");

                ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);

                return;
            }

            if (SyncWaits.TryRemove(Thread, out AutoResetEvent WaitEvent))
            {
                WaitEvent.Set();
            }

            ThreadState.X0 = 0;
        }
Ejemplo n.º 15
0
    private static WaveEvent ProcessWaveEvent(XmlNode node)
    {
        WaveEvent wEvent = null;

        string tag = node.Name;

        switch (tag)
        {
        case "dialog":
            string id = node.Attributes["ref"].InnerText;
            wEvent = new DialogEvent(id);
            break;

        case "enemy":
            int type = int.Parse(node.Attributes["type"].InnerText);
            Debug.Log("Type: " + type);
            int qta   = int.Parse(node.Attributes["qta"].InnerText);
            int delay = int.Parse(node.Attributes["delay"].InnerText);
            wEvent = new GenerateEnemyEvent((UFOType)type, qta, delay);
            break;

        case "wait":
            wEvent = new WaitEvent();
            break;

        case "delay":
            int time = int.Parse(node.Attributes["seconds"].InnerText);
            wEvent = new DelayEvent(time);
            break;

        case "powerup":
            //int ptype = int.Parse(node.Attributes["type"].InnerText);
            wEvent = new PowerUpEvent();
            break;
        }

        return(wEvent);
    }
Ejemplo n.º 16
0
        public void PutValue(byte sid, byte[] data)
        {
            Sid = sid;

            switch (RecType)
            {
            case RecDataType.error:
                CmdSuccess = false;
                break;

            case RecDataType._uint16:
                Data = Tool.ToShorts(data);
                break;

            case RecDataType._uint32:
                Int32Data = Tool.ToInt32(data);
                break;

            case RecDataType.Little_float:
                FloatData = Tool.LitToFloats(data);
                break;

            case RecDataType.Big_float:
                FloatData = Tool.BigToFloats(data);
                break;

            case RecDataType.DO_float:
                FloatData = Tool.DoFloats(data);
                break;

            default:
                break;
            }

            WaitEvent.Set();
        }
Ejemplo n.º 17
0
 private void EditPacketForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     WaitEvent.Set();
 }
Ejemplo n.º 18
0
        public int ReadData(byte[] data, int offset, int length)
        {
            WaitEvent waitEvent = null;

            while (true)
            {
                lock (lockThis)
                {
                    if (stream != null && stream.Length > offset)
                    {
                        if (waitEvent != null)
                        {
                            waitEvents.Remove(waitEvent);
                        }

                        stream.Position = offset;
                        return stream.Read(data, 0, length);
                    }
                    else if (stream == null || Stopped || offset >= stream.Capacity)
                    {
                        return 0;
                    }
                    else if (waitEvent == null)
                    {
                        waitEvent = new WaitEvent();
                        waitEvent.Position = offset;
                        waitEvents.Add(waitEvent);
                    }
                }

                waitEvent.Wait();
            }
        }
Ejemplo n.º 19
0
        public void WaitEvent(WaitEvent waitEvent)
        {
            AsimovLog.WriteLine("Waiting until the event \"{0}\" occurs.", waitEvent);

            this.communicator.ExecuteCommand("WAIT EVENT {0}", (int)waitEvent);
        }
Ejemplo n.º 20
0
        public static IYield Wait(WaitEvent waitEvent)
        {
            if (waitEvent.IsSet())
            {
                Run(Thread.Value);
                return None();
            }

            waitEvent.AddWaitMicrothread(Thread.Value);
            return new WaitEventYield();
        }
Ejemplo n.º 21
0
 public void Dispose()
 {
     Marshal.FreeCoTaskMem(OverlappedStruct);
     WaitEvent.Dispose();
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 22
0
 public MyRunnable1(WaitEvent w)
 {
     this.w = w;
 }
Ejemplo n.º 23
0
    public void Wait(float waitDuration)
    {
        WaitEvent wEvent = new WaitEvent(waitDuration);

        eventQueue.Enqueue(wEvent);
    }
Ejemplo n.º 24
0
 public bool Wait(TimeSpan waitTime)
 {
     return(WaitEvent.WaitOne(waitTime));
 }