Click here to Skip to main content
15,911,786 members
Home / Discussions / C#
   

C#

 
QuestionBreak long line of code into short lines Pin
devinzhang22-Dec-05 8:17
devinzhang22-Dec-05 8:17 
AnswerRe: Break long line of code into short lines Pin
Stanciu Vlad22-Dec-05 10:22
Stanciu Vlad22-Dec-05 10:22 
GeneralRe: Break long line of code into short lines Pin
devinzhang22-Dec-05 15:36
devinzhang22-Dec-05 15:36 
Questionshows program status Pin
zhujp9822-Dec-05 6:37
zhujp9822-Dec-05 6:37 
AnswerRe: shows program status Pin
Stanciu Vlad22-Dec-05 7:01
Stanciu Vlad22-Dec-05 7:01 
GeneralRe: shows program status Pin
zhujp9822-Dec-05 7:04
zhujp9822-Dec-05 7:04 
GeneralRe: shows program status Pin
Stanciu Vlad22-Dec-05 7:08
Stanciu Vlad22-Dec-05 7:08 
GeneralRe: shows program status Pin
Curtis Schlak.22-Dec-05 7:27
Curtis Schlak.22-Dec-05 7:27 
Here's some code. No comments, though. I'm sick today and don't feel that loquacious. Hope it helps.
using System;
using System.Threading;
using System.Windows.Forms;

namespace Project1
{
	public class MainForm : Form
	{
		private OtherForm otherForm;

		public MainForm()
		{
			otherForm = new OtherForm();
			Button b = new Button();
			b.Text = "Click Me";
			b.Click += new EventHandler( RunAThread );
			Controls.Add( b );
		}

		private void RunAThread( object sender, EventArgs ea )
		{
			otherForm.Show();
			ThreadWorker tw = new ThreadWorker( otherForm.tb, new OtherForm.UpdateText( otherForm.UpdateTextBoxText ) );
			Thread t = new Thread( new ThreadStart( tw.RunAlotOfIterations ) );
			t.IsBackground = true;
			t.Start();
		}

		[STAThread]
		public static void Main( string[] args )
		{
			Application.Run( new MainForm() );
		}
	}

	public class OtherForm : Form
	{
		public TextBox tb;
		public OtherForm()
		{
			tb = new TextBox();
			tb.Dock = DockStyle.Fill;
			Controls.Add( tb );
		}
		public delegate void UpdateText( string text );
		public void UpdateTextBoxText( string text )
		{
			Controls[ 0 ].Text = text;
		}
	}

	public class ThreadWorker
	{
		private Control c;
		private OtherForm.UpdateText ut;
		public ThreadWorker( Control target, OtherForm.UpdateText del )
		{
			c = target;
			ut = del;
		}
		public void RunAlotOfIterations()
		{
			for( int i = 1; i < 1000000; i++ )
			{
				c.Invoke( ut, new object[] { i.ToString() } );
			}
		}
	}
}


"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
AnswerRe: shows program status Pin
Dave Kreskowiak22-Dec-05 15:34
mveDave Kreskowiak22-Dec-05 15:34 
QuestionDataGrid updates from a combo box in C# Pin
AuZi200522-Dec-05 6:26
AuZi200522-Dec-05 6:26 
AnswerRe: DataGrid updates from a combo box in C# Pin
Stanciu Vlad22-Dec-05 7:04
Stanciu Vlad22-Dec-05 7:04 
GeneralRe: DataGrid updates from a combo box in C# Pin
AuZi200522-Dec-05 8:15
AuZi200522-Dec-05 8:15 
QuestionWinforms, Datagrids, Hyperlinks and Excel Pin
scotlandc22-Dec-05 6:25
scotlandc22-Dec-05 6:25 
QuestionMenu like functionality Pin
VPMahank22-Dec-05 5:23
VPMahank22-Dec-05 5:23 
Questionopen a excel interface in my c# form Pin
Sasuko22-Dec-05 5:04
Sasuko22-Dec-05 5:04 
AnswerRe: open a excel interface in my c# form Pin
KaptinKrunch22-Dec-05 7:09
KaptinKrunch22-Dec-05 7:09 
QuestionBook Pin
fmardani22-Dec-05 4:41
fmardani22-Dec-05 4:41 
QuestionAuto Update for my application Pin
.NetRocker22-Dec-05 4:35
.NetRocker22-Dec-05 4:35 
AnswerRe: Auto Update for my application Pin
J4amieC22-Dec-05 5:34
J4amieC22-Dec-05 5:34 
AnswerRe: Auto Update for my application Pin
Xodiak22-Dec-05 10:57
Xodiak22-Dec-05 10:57 
GeneralRe: Auto Update for my application Pin
.NetRocker23-Dec-05 5:47
.NetRocker23-Dec-05 5:47 
QuestionConnecting to a remote DB from a service Pin
Marc Clifton22-Dec-05 4:19
mvaMarc Clifton22-Dec-05 4:19 
AnswerRe: Connecting to a remote DB from a service Pin
.NetRocker22-Dec-05 4:54
.NetRocker22-Dec-05 4:54 
AnswerRe: Connecting to a remote DB from a service Pin
HerbCSO22-Dec-05 12:56
HerbCSO22-Dec-05 12:56 
QuestionHttpApplication Pin
talbot22-Dec-05 4:15
talbot22-Dec-05 4:15 

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.