public void ShowMsgCallback(object displayer) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. int n = 0; Type type = displayer.GetType(); dynamic obj = Convert.ChangeType(displayer, type); while (obj.IsHandleCreated == false) { //解决窗体关闭时出现“访问已释放句柄“的异常 if (obj.Disposing || obj.IsDisposed) { return; } Application.DoEvents(); Thread.Sleep(1); if (n++ > 100) { return; } } //如果调用控件的线程和创建创建控件的线程不是同一个则为True if (obj.InvokeRequired) { DisplayCallback d = new DisplayCallback(ShowMsgCallback); obj.BeginInvoke(d, new object[] { displayer }); } else { showmsg(obj); } }
public void Display(string info, bool err) { /* if Display() is not invoked at ui thread */ if (this.messageTextBox.InvokeRequired) { while (!this.messageTextBox.IsHandleCreated) { /* * if the messageBox is disposed or disposing, * cancel the invoking */ if (this.messageTextBox.Disposing || this.messageTextBox.IsDisposed) { return; } } DisplayCallback callback = new DisplayCallback(Display); try { this.messageTextBox.Invoke(callback, new object[] { info, false }); } catch (Exception) { /* */ } } /* else do it as usual */ else { this.messageTextBox.Text += info; } }
/// <summary> /// Class initialised with Callback routines. /// </summary> public GSDisplay() { _callback = new DisplayCallback(); _callback.size = Marshal.SizeOf(_callback); _callback.version_minor = Displayconst.DISPLAY_VERSION_MINOR; _callback.version_major = Displayconst.DISPLAY_VERSION_MAJOR; _callback.DisplayOpen = new display_open_callback(Display_Open); _callback.DisplayPreclose = new display_preclose_callback(Display_Preclose); _callback.DisplayClose = new display_close_callback(Display_Close); _callback.DisplayPresize = new display_presize_callback(Display_Presize); _callback.DisplaySize = new display_size_callback(Display_Size); _callback.DisplaySync = new display_sync_callback(Display_Sync); _callback.DisplayPage = new display_page_callback(Display_Page); _callback.DisplayUpdate = null;// new display_update_callback(Display_Update); - Not used }
private IEnumerator DisplaySequenceCoroutine(ShipActorController[] sequence, DisplayCallback callback) { float waitTime = GameManager.Instance.WaitTime; yield return(new WaitForSeconds(waitTime)); for (int i = 0; i < sequence.Length; i++) { int index = sequence[i].id; ShipActorController actor = this.actors[index]; actor.Show(true); yield return(new WaitForSeconds(waitTime)); actor.Show(false); yield return(new WaitForSeconds(waitTime / 2)); } callback(); }
/// <summary> /// We need to update the form, but sometimes we need to do it from /// another context. If invoke is required, then this method wraps /// itself in a delegate and passes it to Invoke so it can be called /// properly. /// </summary> private void Display(string s) { if (this.logBox.InvokeRequired) { DisplayCallback d = new DisplayCallback(this.Display); try { this.Invoke(d, new object[] { s }); } catch { } } else if (!this.isClosing) { this.logBox.AppendText(s); this.logBox.SelectionStart = this.logBox.TextLength; // Make sure the window scrolls down with new text as expected. this.logBox.ScrollToCaret(); } }
public static void GlutDisplayFunc([In] DisplayCallback func) { _displayCallback = func; glutDisplayFunc(_displayCallback); }
private static extern void glutDisplayFunc(DisplayCallback func);
/////////////////////////////////////////////////////////////////////////////// // Public Methods... /////////////////////////////////////////////////////////////////////////////// #region Public Methods... /// <summary> /// Initialize interesting stuff... /// </summary> /// <param name="a_blNeedBrowser">we need a browser for authentication</param> /// <param name="a_displaycallback">display callback function or null</param> /// <param name="a_stopnotification">notification that we've stopped monitoring</param> /// <param name="m_confirmscan">confirmation function or null</param> /// <param name="a_blNoDevices">true if we have no devices</param> public Scanner ( bool a_blNeedBrowser, DisplayCallback a_displaycallback, StopNotification a_stopnotification, TwainLocalScanner.ConfirmScan a_confirmscan, float a_fConfirmScanScale, out bool a_blNoDevices ) { bool blUseSane; string szExecutablePath = null; string szReadFolder = null; string szWriteFolder = null; // Init stuff... m_blUseXmpp = true; a_blNoDevices = true; m_displaycallback = a_displaycallback; m_stopnotification = a_stopnotification; m_confirmscan = a_confirmscan; m_fConfirmScanScale = a_fConfirmScanScale; m_iDiagnostics = 1; // Get the config and command line argument values... szExecutablePath = Config.Get("executablePath", ""); szReadFolder = Config.Get("readFolder", ""); szWriteFolder = Config.Get("writeFolder", ""); blUseSane = (Config.Get("usesane", null) != null); // Init stuff... m_blUseXmpp = false; // Sanity check... if (!FindTwainDirectOnTwain(szExecutablePath, blUseSane)) { if (blUseSane) { Log.Error("Unable to locate TwainDirectOnSane.exe"); throw new Exception("Unable to locate TwainDirectOnSane.exe"); } else { Log.Error("Unable to locate TwainDirectOnTwain.exe"); throw new Exception("Unable to locate TwainDirectOnTwain.exe"); } } // Get our TWAIN Local interface... m_twainlocalscanner = new TwainLocalScanner ( m_blUseXmpp?MonitorTasks:(TimerCallback)null, a_confirmscan, a_fConfirmScanScale, m_blUseXmpp?this:(object)null ); if (m_twainlocalscanner == null) { Log.Error("Failed to create TwainLocalScanner"); throw new Exception("Failed to create TwainLocalScanner"); } // Do we have any devices? a_blNoDevices = RefreshDeviceList(); }
public void DisplaySequence(ShipActorController[] sequence, DisplayCallback callback) { StartCoroutine(this.DisplaySequenceCoroutine(sequence, callback)); }
/// <summary> /// Sets the display callback for the current window. /// </summary> /// <param name="func"> /// The new display callback function. See <see cref="DisplayCallback" />. /// </param> /// <remarks> /// <para> /// <b>glutDisplayFunc</b> sets the display callback for the current window. When /// GLUT determines that the normal plane for the window needs to be redisplayed, /// the display callback for the window is called. Before the callback, the /// current window is set to the window needing to be redisplayed and (if no /// overlay display callback is registered) the layer in use is set to the normal /// plane. The display callback is called with no parameters. The entire normal /// plane region should be redisplayed in response to the callback (this includes /// ancillary buffers if your program depends on their state). /// </para> /// <para> /// GLUT determines when the display callback should be triggered based on the /// window's redisplay state. The redisplay state for a window can be either set /// explicitly by calling <see cref="glutPostRedisplay" /> or implicitly as the /// result of window damage reported by the window system. Multiple posted /// redisplays for a window are coalesced by GLUT to minimize the number of /// display callbacks called. /// </para> /// <para> /// When an overlay is established for a window, but there is no overlay display /// callback registered, the display callback is used for redisplaying both the /// overlay and normal plane (that is, it will be called if either the redisplay /// state or overlay redisplay state is set). In this case, the layer in use is /// not implicitly changed on entry to the display callback. /// </para> /// <para> /// See <see cref="glutOverlayDisplayFunc" /> to understand how distinct callbacks /// for the overlay and normal plane of a window may be established. /// </para> /// <para> /// When a window is created, no display callback exists for the window. It is /// the responsibility of the programmer to install a display callback for the /// window before the window is shown. A display callback must be registered for /// any window that is shown. If a window becomes displayed without a display /// callback being registered, a fatal error occurs. Passing <c>null</c> to /// <b>glutDisplayFunc</b> is illegal as of GLUT 3.0; there is no way to /// "deregister" a display callback (though another callback routine can always be /// registered). /// </para> /// <para> /// Upon return from the display callback, the normal damaged state of the window /// (returned by calling <c>Glut.glutLayerGet(Glut.GLUT_NORMAL_DAMAGED)</c> is /// cleared. If there is no overlay display callback registered the overlay /// damaged state of the window (returned by calling /// <c>Glut.glutLayerGet(Glut.GLUT_OVERLAY_DAMAGED)</c> is also cleared. /// </para> /// </remarks> /// <seealso cref="DisplayCallback" /> /// <seealso cref="glutLayerGet" /> /// <seealso cref="glutOverlayDisplayFunc" /> // GLUTAPI void APIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void)); public static void glutDisplayFunc([In] DisplayCallback func) { displayCallback = func; __glutDisplayFunc(displayCallback); }
private static extern void __glutDisplayFunc(DisplayCallback func);
private void Display(string s) { if (textBox_Status.InvokeRequired) { DisplayCallback d = new DisplayCallback(this.Display); try { this.Invoke(d, new object[] { s }); } catch { } } else { textBox_Status.AppendText(s + "\n"); textBox_Status.SelectionStart = textBox_Status.TextLength; // This stuff is necessary to make sure the text window will // scroll down as we would expect it to. textBox_Status.ScrollToCaret(); } }
public static extern bool PlayM4_SetDisplayCallBack(uint nPort, DisplayCallback callback);