/// <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[] { }); }
internal static extern int TextHostInit( ProcessCallback OnConnect, ProcessCallback OnDisconnect, OnCreateThread OnCreateThread, OnRemoveThread OnRemoveThread, OnOutputText OnOutputText );
private void LoadProcess(float p) { if (null != ProcessCallback) { ProcessCallback.Invoke(p); } }
private void DispatchCallback(ProcessCallback callback) { foreach (ProcessDataObject pdo in MainListView.SelectedItems) { callback(pdo); } }
/// <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)); }
public void InitAutoReadConfig() { callback = (slave, channel, value) => { AutoDataChanged(null, new DataChangedEventArgs(slave, channel, value)); }; //binding callback. HtEcConnector.doWork(callback); }
//////////////////////////////////////////////////////////// /// <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); }
//////////////////////////////////////////////////////////// /// <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)); }
public bool ExecuteWithTempArguments(T tempArguments, ProcessCallback callback, string workingDirectory = null) { T savedArgs = Arguments; Arguments = tempArguments; bool result = Execute(callback, workingDirectory); Arguments = savedArgs; return(result); }
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(); } }
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); }
public static extern int doWork([MarshalAs(UnmanagedType.FunctionPtr)] ProcessCallback callbackPoint);
public FakeServiceConnector(ProcessCallback callback) { this.callback = callback; }
public Connector() { actionWriter = new ConnectorActionCallback(this); processCallback = new ProcessCallback(); processCallback.OnMessage += processCallbackOnMessage; }
static void Process(string Message, ProcessCallback Process) { Console.Write(Message + "..."); Process(); Console.WriteLine("OK"); }
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[] { }); }
static extern IntPtr sfSoundRecorder_Create(StartCallback OnStart, ProcessCallback OnProcess, StopCallback OnStop, IntPtr UserData);
public bool Execute(ProcessCallback callback, string workingDirectory = null) { string arguments = BuildArgumentsString(); return(DoExecute(arguments, workingDirectory, callback)); }
protected abstract bool DoExecute(string arguments, string workingDirectory, ProcessCallback callback = null);
static extern IntPtr sfSoundRecorder_create(StartCallback OnStart, ProcessCallback OnProcess, StopCallback OnStop, IntPtr UserData);
static public void SetProcessCallback(ProcessCallback cb) { _ProcessCallback = cb; }