private static extern void _initLogCallback(logCallback callback);
Пример #2
0
        //Log some text
        private void log(string text)
        {
            //If we're currently in a worker thread, call this method on the GUI thread
            if(txtLog.InvokeRequired)
            {
                logCallback logCallbackDelegate = new logCallback(log);
                //Run the function again (passed as a delegate) on the GUI thread using the Invoke method
                this.Invoke(logCallbackDelegate, new object[] { text });
            }
            else //Otherwise we're on the thread in charge of the Form, manipulate it
            {
                //If the text box already has content, then add a new line before appending this
                if (txtLog.Text != "")
                {
                    txtLog.Text += Environment.NewLine;
                }

                //Append this text to the log
                txtLog.Text += text;
            }
        }