Click here to Skip to main content
15,888,031 members
Home / Discussions / C#
   

C#

 
QuestionAuto tune channels in DirectX.Capture Pin
ranandbe17-May-06 19:27
ranandbe17-May-06 19:27 
AnswerRe: Auto tune channels in DirectX.Capture Pin
leppie17-May-06 19:33
leppie17-May-06 19:33 
Question Problem in opening model dialog window from worker thread Pin
Krrish17-May-06 19:13
Krrish17-May-06 19:13 
AnswerRe: Problem in opening model dialog window from worker thread Pin
leppie17-May-06 19:31
leppie17-May-06 19:31 
AnswerRe: Problem in opening model dialog window from worker thread Pin
S. Senthil Kumar17-May-06 19:42
S. Senthil Kumar17-May-06 19:42 
AnswerRe: Pin
stancrm18-May-06 3:35
stancrm18-May-06 3:35 
GeneralRe: Pin
Krrish22-May-06 0:24
Krrish22-May-06 0:24 
GeneralRe: Pin
stancrm22-May-06 0:51
stancrm22-May-06 0:51 
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;

namespace WindowsApplication5
{
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.ComponentModel.Container components = null;

		public Form1()
		{	InitializeComponent(); }

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{ components.Dispose(); }
			}
			base.Dispose( disposing );
		}

		private void InitializeComponent()
		{
			this.button1 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			this.button1.Location = new System.Drawing.Point(48, 72);
			this.button1.Name = "button1";
			this.button1.TabIndex = 1;
			this.button1.Text = "Change text";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(208, 189);
			this.Controls.Add(this.button1);
			this.Name = "Form1";
			this.Text = "Form1";
			this.ResumeLayout(false);
		}

		[STAThread]
		static void Main() 
		{	Application.Run(new Form1()); }

		private void button1_Click(object sender, System.EventArgs e)
		{
			/***** WRONG *****/
//			Thread t = new Thread(new ThreadStart(Run));
//			t.Start();

			/***** OK ******/
			Thread t = new Thread(new ThreadStart(CreateNewLabel));
			t.Start();
		}

		private void CreateNewLabel()
		{
			MethodInvoker minvoker = new MethodInvoker(Run);
			Invoke(minvoker);
		}

		private void Run()
		{
			try
			{
				Label label = new Label();
				label.Name = "MyLabel";
				label.Text = "MyLabel";
				label.Location = new Point(50, 50);
				this.Controls.Add(label);
			}
			catch(Exception ex)
			{	MessageBox.Show(ex.ToString());	}
		}
	}
}

You cannot call method "Run" directly, because method "Run" is in another thread. That's why you must call the method CreateNewLabel to create a new label from another thread. You can find the complete description in : http://www.oreilly.de/catalog/csharpnutger/chapter/ch04.html
That site is in german, you can use www.google.com/translate to translate it in english.
Questionform Authenication with users in databse Pin
saud_a_k17-May-06 18:44
saud_a_k17-May-06 18:44 
AnswerRe: form Authenication with users in databse Pin
Kakuji17-May-06 18:52
Kakuji17-May-06 18:52 
GeneralRe: form Authenication with users in databse Pin
saud_a_k17-May-06 19:01
saud_a_k17-May-06 19:01 
GeneralRe: form Authenication with users in databse Pin
Colin Angus Mackay17-May-06 23:42
Colin Angus Mackay17-May-06 23:42 
GeneralRe: form Authenication with users in databse Pin
Colin Angus Mackay17-May-06 23:42
Colin Angus Mackay17-May-06 23:42 
AnswerRe: form Authenication with users in databse Pin
Colin Angus Mackay17-May-06 23:45
Colin Angus Mackay17-May-06 23:45 
GeneralRe: form Authenication with users in databse Pin
saud_a_k18-May-06 0:17
saud_a_k18-May-06 0:17 
QuestionDotNetNuke Skin Pin
Kakuji17-May-06 18:41
Kakuji17-May-06 18:41 
AnswerRe: DotNetNuke Skin Pin
leppie17-May-06 19:10
leppie17-May-06 19:10 
QuestionAdding new Rows to the Data base table Pin
Ashraj198217-May-06 18:21
Ashraj198217-May-06 18:21 
AnswerRe: Adding new Rows to the Data base table Pin
leppie17-May-06 19:12
leppie17-May-06 19:12 
GeneralRe: Adding new Rows to the Data base table Pin
rah_sin17-May-06 19:17
professionalrah_sin17-May-06 19:17 
GeneralRe: Adding new Rows to the Data base table Pin
leppie17-May-06 19:28
leppie17-May-06 19:28 
Questionhow to user mail merge feature of microsoft word from c# Pin
Amrit pal Singh17-May-06 18:19
Amrit pal Singh17-May-06 18:19 
QuestionSending multiple files through same TCP connection! Pin
eyej17-May-06 15:36
eyej17-May-06 15:36 
AnswerRe: Sending multiple files through same TCP connection! Pin
led mike17-May-06 18:15
led mike17-May-06 18:15 
AnswerRe: Sending multiple files through same TCP connection! Pin
leppie17-May-06 19:07
leppie17-May-06 19:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.