Click here to Skip to main content
15,915,603 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to know if a place holder is empty Pin
Rob Graham3-Mar-05 15:28
Rob Graham3-Mar-05 15:28 
GeneralRe: How to know if a place holder is empty Pin
see074-Mar-05 9:28
see074-Mar-05 9:28 
Generalsorting datagrid with empty rows Pin
Mc Fetto3-Mar-05 9:32
Mc Fetto3-Mar-05 9:32 
GeneralSelection Color Pin
Radgar3-Mar-05 7:39
Radgar3-Mar-05 7:39 
GeneralCalculations on Dataset Urgent Please help Pin
nishant.gogia3-Mar-05 7:37
nishant.gogia3-Mar-05 7:37 
GeneralRe: Calculations on Dataset Urgent Please help Pin
Kodanda Pani3-Mar-05 16:17
Kodanda Pani3-Mar-05 16:17 
GeneralRe: Calculations on Dataset Urgent Please help Pin
nishant.gogia3-Mar-05 17:07
nishant.gogia3-Mar-05 17:07 
GeneralProblems when going from framework 1.1 to 2.0 beta Pin
Talal Sultan3-Mar-05 7:23
Talal Sultan3-Mar-05 7:23 
Hi people,

I have a running small windows forms application on 1.0 and 1.1, but when I use the code on 2.0 beta, it says that the thread cannot access an object that it hasn't createdConfused | :confused: . Can anyone check this out for me please? I have 2 files, one called Main.cs, which is the main program and then I have Ticker.cs which is another window class called from Main. I will post below the whole code for both files, if anyone has any clue about that.
I am using SharpDevelop for 1.1 and Visual C# Express 2005 beta for 2.0

Main.cs
<br />
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Threading;<br />
<br />
<br />
namespace Exercice1<br />
{<br />
	/// <summary><br />
	/// Summary description for Form1.<br />
	/// </summary><br />
	public class Form1 : System.Windows.Forms.Form<br />
	{<br />
		private System.Windows.Forms.Label label1;<br />
		private System.Windows.Forms.Label lblText;<br />
		private System.Windows.Forms.Button btnClose;<br />
		private System.Windows.Forms.Timer timer;<br />
		private System.ComponentModel.IContainer components;<br />
		private System.Windows.Forms.ProgressBar progressBar1;<br />
<br />
<br />
<br />
		/// <summary><br />
		/// Required designer variable.<br />
		/// </summary><br />
		//private System.ComponentModel.Container components = null;<br />
<br />
		public Form1()<br />
		{<br />
			//<br />
			// Required for Windows Form Designer support<br />
			//<br />
			InitializeComponent();<br />
<br />
			//<br />
			// TODO: Add any constructor code after InitializeComponent call<br />
			//<br />
		}<br />
<br />
		/// <summary><br />
		/// Clean up any resources being used.<br />
		/// </summary><br />
		protected override void Dispose( bool disposing )<br />
		{<br />
			if( disposing )<br />
			{<br />
				if (components != null) <br />
				{<br />
					components.Dispose();<br />
				}<br />
			}<br />
			base.Dispose( disposing );<br />
		}<br />
<br />
		#region Windows Form Designer generated code<br />
		/// <summary><br />
		/// Required method for Designer support - do not modify<br />
		/// the contents of this method with the code editor.<br />
		/// </summary><br />
		private void InitializeComponent()<br />
		{<br />
<br />
			this.components = new System.ComponentModel.Container();<br />
			this.timer = new System.Windows.Forms.Timer(this.components);<br />
			this.label1 = new System.Windows.Forms.Label();<br />
			this.lblText = new System.Windows.Forms.Label();<br />
			this.btnClose = new System.Windows.Forms.Button();<br />
			this.progressBar1 = new System.Windows.Forms.ProgressBar();<br />
			this.SuspendLayout();<br />
			// <br />
			// label1<br />
			// <br />
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<br />
			this.label1.Location = new System.Drawing.Point(16, 16);<br />
			this.label1.Name = "label1";<br />
			this.label1.Size = new System.Drawing.Size(264, 23);<br />
			this.label1.TabIndex = 0;<br />
			this.label1.Text = "Welcome";<br />
			// <br />
			// lblText<br />
			// <br />
			this.lblText.Location = new System.Drawing.Point(16, 56);<br />
			this.lblText.Name = "lblText";<br />
			this.lblText.Size = new System.Drawing.Size(264, 23);<br />
			this.lblText.TabIndex = 1;<br />
			this.lblText.Text = "Loading XYZ...";<br />
			// <br />
			// btnClose<br />
			// <br />
			this.btnClose.Location = new System.Drawing.Point(208, 128);<br />
			this.btnClose.Name = "btnClose";<br />
			this.btnClose.TabIndex = 2;<br />
			this.btnClose.Text = "Cancel";<br />
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);<br />
			// <br />
			// progressBar1<br />
			// <br />
			this.progressBar1.Location = new System.Drawing.Point(16, 96);<br />
			this.progressBar1.Name = "progressBar1";<br />
			this.progressBar1.Size = new System.Drawing.Size(264, 23);<br />
			this.progressBar1.Step = 1;<br />
			this.progressBar1.Minimum=0;<br />
			this.progressBar1.Maximum=20;<br />
			this.progressBar1.TabIndex = 3;<br />
			// <br />
			// timer<br />
			// <br />
			this.timer.Enabled = true;<br />
			this.timer.Interval = 300;<br />
			this.timer.Tick += new System.EventHandler(this.timer_Tick);<br />
			// <br />
			// Form1<br />
			// <br />
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
			this.ClientSize = new System.Drawing.Size(294, 175);<br />
			this.Controls.AddRange(new System.Windows.Forms.Control[] {<br />
																		  this.progressBar1,<br />
																		  this.btnClose,<br />
																		  this.lblText,<br />
																		  this.label1});<br />
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;<br />
			this.Name = "SplashForm";<br />
			this.Text = "Loading MyApp...";<br />
			this.Load += new System.EventHandler(this.SpashForm_Load);<br />
			this.ResumeLayout(false);<br />
<br />
		}<br />
		#endregion<br />
	<br />
		private void btnClose_Click(object sender, System.EventArgs e)<br />
		{<br />
			this.DialogResult = DialogResult.Cancel;<br />
			this.Close();<br />
		}<br />
		<br />
		private void timer_Tick(object sender, System.EventArgs e)<br />
		{<br />
			if (progressBar1.Value != progressBar1.Maximum)<br />
			{<br />
				progressBar1.PerformStep();<br />
					<br />
			}<br />
			else<br />
			{<br />
				this.timer.Tick -= new System.EventHandler(this.timer_Tick);<br />
				Ticker t1 = new Ticker();<br />
				t1.Show();<br />
				this.Hide();<br />
			}<br />
				<br />
		}<br />
<br />
		private void SpashForm_Load(object sender, System.EventArgs e)<br />
		{<br />
			if (progressBar1.Value == progressBar1.Maximum)<br />
			{<br />
				<br />
			}<br />
		}<br />
		protected override void OnClosing(CancelEventArgs e) <br />
		{<br />
			this.Dispose();<br />
			Environment.Exit(0);<br />
<br />
		}<br />
		/// <summary><br />
		/// The main entry point for the application.<br />
		/// </summary><br />
		[STAThread]<br />
		static void Main() <br />
		{<br />
			Application.Run(new Form1());<br />
		}<br />
	}<br />
<br />
	<br />
}<br />
<br />


Ticker.cs
<br />
using System;<br />
using System.Windows.Forms;<br />
using System.ComponentModel;<br />
using System.Drawing;<br />
using System.Threading;<br />
using System.IO;<br />
<br />
namespace Exercice1 {<br />
	<br />
	public class Ticker : Form {<br />
		<br />
		Label label1, label2;<br />
		<br />
		String[] newsItems =<br />
		{ "Safest Aerobic Machine Launched",<br />
			"First Dog Cloning Is Only Days Away",<br />
			"Reviving the Extinct Tasmanian Tiger" };<br />
		<br />
		String[] businessItems =<br />
		{ "FirstMeasure Software to Go Nasdaq",<br />
			"MFMF Directors To Meet For The First Time",<br />
			"First Sign of Economic Recovery Finally At Sight",<br />
			"Euro Hits Record Low (Again)" };<br />
		<br />
		<br />
<br />
		public Thread NewsThread,BusinessThread;<br />
		<br />
		//  public static void Main() {<br />
		//    Ticker ticker = new Ticker();<br />
		//    Application.Run(ticker);<br />
		//  }<br />
		<br />
		public Ticker() {<br />
			Initialize();<br />
			StartThread();<br />
		}<br />
		#region Windows Form Designer generated code<br />
		/// <summary><br />
		/// Required method for Designer support - do not modify<br />
		/// the contents of this method with the code editor.<br />
		/// </summary>		<br />
		private void Initialize() {<br />
			this.Height = 100;<br />
			<br />
			label1 = new Label();<br />
			label2 = new Label();<br />
			<br />
			label1.Width = 280;<br />
			label1.Height = 30;<br />
			label1.Location = new Point(1, 10);<br />
			label1.TextAlign = ContentAlignment.MiddleRight;<br />
			<br />
			label2.Width = 280;<br />
			label2.Height = 30;<br />
			label2.Location = new Point(1, 40);<br />
			<br />
			this.Controls.Add(label1);<br />
			this.Controls.Add(label2);<br />
		}<br />
		#endregion<br />
		<br />
		private void StartThread() {<br />
			<br />
			NewsThread = new Thread(new ThreadStart(MoveLeft));<br />
			BusinessThread = new Thread(new ThreadStart(MoveRight));<br />
			NewsThread.Start();<br />
			BusinessThread.Start();<br />
			//MoveLeft();<br />
		}<br />
		<br />
		private  void MoveLeft() {<br />
			// <br />
			string labelText;<br />
			while(true)<br />
			{<br />
<br />
				foreach(string item in newsItems)<br />
				{<br />
					labelText = item;<br />
					label1.Text=labelText;<br />
<br />
					for (int i=280;i>1;i--)<br />
					{<br />
						label1.Location = new Point(i, 10);<br />
					<br />
						Thread.Sleep(10);<br />
					}<br />
<br />
					Thread.Sleep(500);<br />
				}<br />
			}<br />
		}<br />
		<br />
		private void MoveRight() <br />
		{<br />
			string labelText;<br />
<br />
			while(true)<br />
			{<br />
				foreach(string item in businessItems)<br />
				{<br />
					labelText = item;<br />
					label2.Text="";<br />
					int textLength = labelText.Length;<br />
<br />
					for (int i=0;i<textLength;i++)<br />
					{<br />
						label2.Text+=labelText[i];<br />
						Thread.Sleep(50);<br />
					}<br />
				<br />
<br />
					Thread.Sleep(500);<br />
				}<br />
			}<br />
		}<br />
		<br />
		protected override void OnClosing(CancelEventArgs e) {<br />
			<br />
			NewsThread.Abort();<br />
			BusinessThread.Abort();<br />
			this.Dispose();<br />
			Environment.Exit(0);<br />
<br />
		}<br />
		<br />
		<br />
	}<br />
}<br />
<br />


Thank you!
Talal


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
GeneralRe: Problems when going from framework 1.1 to 2.0 beta Pin
Judah Gabriel Himango3-Mar-05 7:55
sponsorJudah Gabriel Himango3-Mar-05 7:55 
GeneralRe: Problems when going from framework 1.1 to 2.0 beta Pin
Talal Sultan3-Mar-05 11:24
Talal Sultan3-Mar-05 11:24 
GeneralRe: Problems when going from framework 1.1 to 2.0 beta Pin
S. Senthil Kumar3-Mar-05 7:59
S. Senthil Kumar3-Mar-05 7:59 
GeneralRe: Problems when going from framework 1.1 to 2.0 beta Pin
Talal Sultan3-Mar-05 11:30
Talal Sultan3-Mar-05 11:30 
GeneralDateTime problem Pin
Anonymous3-Mar-05 6:34
Anonymous3-Mar-05 6:34 
GeneralRe: DateTime problem Pin
sreejith ss nair3-Mar-05 9:22
sreejith ss nair3-Mar-05 9:22 
GeneralRe: DateTime problem Pin
Anonymous3-Mar-05 10:30
Anonymous3-Mar-05 10:30 
Questionenybody Know...??? Pin
ABBASI_RA3-Mar-05 3:55
ABBASI_RA3-Mar-05 3:55 
General,.net security related problem Pin
montu33773-Mar-05 3:46
montu33773-Mar-05 3:46 
GeneralRe: ,.net security related problem Pin
Judah Gabriel Himango3-Mar-05 6:39
sponsorJudah Gabriel Himango3-Mar-05 6:39 
Questionis there a concept of const function parameters? Pin
feline_dracoform3-Mar-05 3:33
feline_dracoform3-Mar-05 3:33 
AnswerRe: is there a concept of const function parameters? Pin
S. Senthil Kumar3-Mar-05 7:17
S. Senthil Kumar3-Mar-05 7:17 
GeneralDll Import ( C++ Dll) and the result array Pin
Anonymous3-Mar-05 3:03
Anonymous3-Mar-05 3:03 
GeneralGet fusing of two pixels Pin
Anonymous3-Mar-05 2:11
Anonymous3-Mar-05 2:11 
GeneralRe: Get fusing of two pixels Pin
leppie3-Mar-05 9:01
leppie3-Mar-05 9:01 
GeneralRe: Get fusing of two pixels Pin
Sasuko3-Mar-05 11:53
Sasuko3-Mar-05 11:53 
QuestionWhere to store data? Pin
chilberto3-Mar-05 0:40
chilberto3-Mar-05 0:40 

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.