/// <summary>
        /// Recorder callback.
        /// </summary>
        /// <param name="data">Data to fill in.</param>
        /// <param name="size">Buffer size.</param>
        private void _RecordData(IntPtr data, uint size)
        {
            if (_recodingBuffer == null)
            {
                _recodingBuffer = new byte[size];
            }
            else
            {
                Array.Resize(ref _recodingBuffer, (int)size);
            }

            Marshal.Copy(data, _recodingBuffer, 0, (int)size);

            // Process byte stream.
            ProcessCallback ps = new ProcessCallback(_soundProcessing);

            Dispatcher.CurrentDispatcher.Invoke(ps, new object[] { _recodingBuffer.ToList(), data });

            _streamMemory.Write(_recodingBuffer, 0, _recodingBuffer.Length);

            // Update labels.
            PositionChangedCallback pc = new PositionChangedCallback(_PositionChange);

            Dispatcher.CurrentDispatcher.Invoke(pc, new object[] { });
        }
예제 #2
0
 internal static extern int TextHostInit(
     ProcessCallback OnConnect,
     ProcessCallback OnDisconnect,
     OnCreateThread OnCreateThread,
     OnRemoveThread OnRemoveThread,
     OnOutputText OnOutputText
     );
예제 #3
0
파일: Video.cs 프로젝트: ChampionGuan/TLcg
 private void LoadProcess(float p)
 {
     if (null != ProcessCallback)
     {
         ProcessCallback.Invoke(p);
     }
 }
예제 #4
0
 private void DispatchCallback(ProcessCallback callback)
 {
     foreach (ProcessDataObject pdo in MainListView.SelectedItems)
     {
         callback(pdo);
     }
 }
예제 #5
0
            /// <summary>
            /// Default constructor
            /// </summary>
            ////////////////////////////////////////////////////////////
            protected SoundRecorder() : base(IntPtr.Zero)
            {
                myStartCallback = new StartCallback(OnStart);
                myProcessCallback = new ProcessCallback(ProcessSamples);
                myStopCallback = new StopCallback(OnStop);

                SetThis(sfSoundRecorder_Create(myStartCallback, myProcessCallback, myStopCallback, IntPtr.Zero));
            }
예제 #6
0
 public void InitAutoReadConfig()
 {
     callback = (slave, channel, value) =>
     {
         AutoDataChanged(null, new DataChangedEventArgs(slave, channel, value));
     };
     //binding callback.
     HtEcConnector.doWork(callback);
 }
예제 #7
0
            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Default constructor
            /// </summary>
            ////////////////////////////////////////////////////////////
            public SoundRecorder() :
                base(IntPtr.Zero)
            {
                myStartCallback = new StartCallback(OnStart);
                myProcessCallback = new ProcessCallback(ProcessSamples);
                myStopCallback = new StopCallback(OnStop);

                CPointer = sfSoundRecorder_create(myStartCallback, myProcessCallback, myStopCallback, IntPtr.Zero);
            }
예제 #8
0
        ////////////////////////////////////////////////////////////
        /// <summary>
        /// Default constructor
        /// </summary>
        ////////////////////////////////////////////////////////////
        public SoundRecorder() :
            base(IntPtr.Zero)
        {
            myStartCallback   = new StartCallback(OnStart);
            myProcessCallback = new ProcessCallback(ProcessSamples);
            myStopCallback    = new StopCallback(OnStop);

            CPointer = sfSoundRecorder_create(myStartCallback, myProcessCallback, myStopCallback, IntPtr.Zero);
        }
예제 #9
0
            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Default constructor
            /// </summary>
            ////////////////////////////////////////////////////////////
            public SoundRecorder() :
                base(IntPtr.Zero)
            {
                myStartCallback   = new StartCallback(OnStart);
                myProcessCallback = new ProcessCallback(ProcessSamples);
                myStopCallback    = new StopCallback(OnStop);

                SetThis(sfSoundRecorder_Create(myStartCallback, myProcessCallback, myStopCallback, IntPtr.Zero));
            }
예제 #10
0
        public bool ExecuteWithTempArguments(T tempArguments, ProcessCallback callback, string workingDirectory = null)
        {
            T savedArgs = Arguments;

            Arguments = tempArguments;

            bool result = Execute(callback, workingDirectory);

            Arguments = savedArgs;
            return(result);
        }
예제 #11
0
    static void Main(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("usage: process_callback <cps file>");
            return;
        }

        var dataModel = CRootContainer.addDatamodel();

        if (!dataModel.loadModel(args[0]))
        {
            Console.WriteLine("Couldn't open the model: ");
            Console.WriteLine(CCopasiMessage.getAllMessageText());
            return;
        }

        var progress = new ProcessCallback();

        Console.CancelKeyPress += delegate {
            Console.WriteLine("Stop requested ... waiting for process to finish");
            progress.ShouldProceed = false;

            Thread.Sleep(30000);
        };


        for (uint i = 0; i < dataModel.getNumTasks(); ++i)
        {
            var task = dataModel.getTask(i);
            if (!task.isScheduled())
            {
                continue;
            }
            Console.WriteLine(string.Format("Running Scheduled Task: {0}, stop anytime using CTRL+C", task.getObjectName()));

            // set progress support
            task.setCallBack(progress);

            // execute the task
            task.process(true);

            // unset
            task.clearCallBack();
        }
    }
예제 #12
0
        protected override bool DoExecute(string arguments, string workingDirectory, ProcessCallback callback)
        {
            if (string.IsNullOrWhiteSpace(Executable))
            {
                return(false);
            }

            StringBuilder sb = new StringBuilder();

            bool disabledData = false;

            Process proc = new Process();

            proc.StartInfo.FileName = Executable;

            if (!string.IsNullOrWhiteSpace(arguments))
            {
                proc.StartInfo.Arguments = arguments;
            }

            proc.StartInfo.CreateNoWindow = callback != null;
            proc.StartInfo.Verb           = "runas";

            proc.StartInfo.RedirectStandardOutput = callback != null;
            proc.StartInfo.RedirectStandardInput  = callback != null;
            proc.StartInfo.RedirectStandardError  = callback != null;

            proc.StartInfo.UseShellExecute = callback == null;
            if (!string.IsNullOrWhiteSpace(workingDirectory))
            {
                proc.StartInfo.WorkingDirectory = workingDirectory;
            }

            proc.EnableRaisingEvents = callback != null;

            if (callback != null)
            {
                proc.OutputDataReceived += (sender, e) => {
                    if (string.IsNullOrEmpty(e.Data))
                    {
                        return;
                    }

                    sb.Append(e.Data).Append('\n');

                    if (!disabledData && callback(e.Data, ProcType.DATA_RECEIVED))
                    {
                        disabledData = true;
                    }
                };

                proc.Exited += (sender, e) => {
                    proc.Dispose();

                    if (sb.Length > 0)
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }

                    callback(sb.ToString(), ProcType.EXITED);
                };

                proc.ErrorDataReceived += (sender, e) => {
                    callback(e.Data, ProcType.ERROR);
                };
            }
            proc.Start();
            if (callback != null)
            {
                proc.BeginOutputReadLine();
                proc.BeginErrorReadLine();
            }
            return(true);
        }
예제 #13
0
 public static extern int doWork([MarshalAs(UnmanagedType.FunctionPtr)] ProcessCallback callbackPoint);
예제 #14
0
 private void DispatchCallback(ProcessCallback callback)
 {
     foreach (ProcessDataObject pdo in MainListView.SelectedItems)
     {
         callback(pdo);
     }
 }
예제 #15
0
 public FakeServiceConnector(ProcessCallback callback)
 {
     this.callback = callback;
 }
예제 #16
0
 public Connector()
 {
     actionWriter = new ConnectorActionCallback(this);
     processCallback = new ProcessCallback();
     processCallback.OnMessage += processCallbackOnMessage;
 }
예제 #17
0
 static void Process(string Message, ProcessCallback Process)
 {
     Console.Write(Message + "...");
     Process();
     Console.WriteLine("OK");
 }
예제 #18
0
 public FakeServiceConnector(ProcessCallback callback)
 {
     this.callback = callback;
 }
예제 #19
0
 public FakeServiceConnector(FakeAdminService adminService)
 {
     callback = adminService.ProcessCallback;
 }
        /// <summary>
        /// Recorder callback.
        /// </summary>
        /// <param name="data">Data to fill in.</param>
        /// <param name="size">Buffer size.</param>
        private void _RecordData(IntPtr data, uint size)
        {
            if (_recodingBuffer == null)
                _recodingBuffer = new byte[size];
            else
                Array.Resize(ref _recodingBuffer, (int)size);

            Marshal.Copy(data, _recodingBuffer, 0, (int)size);

            // Process byte stream.
            ProcessCallback ps = new ProcessCallback(_soundProcessing);
                Dispatcher.CurrentDispatcher.Invoke(ps, new object[] { _recodingBuffer.ToList(), data });

            _streamMemory.Write(_recodingBuffer, 0, _recodingBuffer.Length);

            // Update labels.
            PositionChangedCallback pc = new PositionChangedCallback(_PositionChange);
            Dispatcher.CurrentDispatcher.Invoke(pc, new object[] { });
        }
예제 #21
0
 static extern IntPtr sfSoundRecorder_Create(StartCallback OnStart, ProcessCallback OnProcess, StopCallback OnStop, IntPtr UserData);
예제 #22
0
        public bool Execute(ProcessCallback callback, string workingDirectory = null)
        {
            string arguments = BuildArgumentsString();

            return(DoExecute(arguments, workingDirectory, callback));
        }
예제 #23
0
 protected abstract bool DoExecute(string arguments, string workingDirectory, ProcessCallback callback = null);
예제 #24
0
 static extern IntPtr sfSoundRecorder_create(StartCallback OnStart, ProcessCallback OnProcess, StopCallback OnStop, IntPtr UserData);
예제 #25
0
 static public void SetProcessCallback(ProcessCallback cb)
 {
     _ProcessCallback = cb;
 }