Hello,

I already have spoken about my problem in this forum. I developed a Smart
Device Application with a Login function. After the login function a screen
with some information is displayed for about five seconds and then be
automatically forwarded to the next Form. I wrote a little code sample and
wouuld ask if this is correct to solve my problem?

using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;

namespace SmartDeviceApplication2
{

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.MainMenu mainMenu1;

private static AutoResetEvent evt;
private static int count = 5;

public Form1()
{

InitializeComponent();


}

protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code


private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(64, 64);
this.textBox1.Text = "textBox1";
//
// label1
//
this.label1.Font = new System.Drawing.Font("Monotype Corsiva", 18F,
System.Drawing.FontStyle.Italic);
this.label1.ForeColor = System.Drawing.Color.LawnGreen;
this.label1.Location = new System.Drawing.Point(16, 8);
this.label1.Size = new System.Drawing.Size(160, 24);
this.label1.Text = "Test";
this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// button1
//
this.button1.Location = new System.Drawing.Point(64, 136);
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(64, 104);
this.label2.Text = "label2";
//
// Form1
//
this.BackColor = System.Drawing.Color.Orange;
this.Controls.Add(this.label2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";

}
#endregion

static void Main()
{
Application.Run(new Form1());
evt = new AutoResetEvent(false);
Timer t = new Timer(new TimerCallback(TimerCallback), null, 5000, 0);
evt.WaitOne();

ActiveForm = Form2;



}

private void button1_Click(object sender, System.EventArgs e)
{
label2.Text = textBox1.Text;
tw.Write("This is the first message!");
}

private static void TimerCallback(object state)
{
evt.Set();
}
}
}

Thanks in Advance

regards

patrick

Re: Forwarding in Smart Device Application by Chris

Chris
Mon Oct 04 08:38:10 CDT 2004

No, this will not work. The problem is that you have a message pump created
by Application.Run for an instance of Form1. Once that Form is closed, Main
will continue, create your event, your timer, wait and then it will exit,
closing the app. You're better off loading an instance of Form2 with a
pump, then in it's ctor showing Form1 for a period of time.

Once again I'm going to highly recommend that you learn to walk before
trying to run. Get a good tutorial book on managed code and go through it.
This question would be just as applicable on the desktop, so any .NET
development book would apply.

-Chris




"pat" <pat@discussions.microsoft.com> wrote in message
news:48CF9094-322A-48D8-948B-24D220210B54@microsoft.com...
> Hello,
>
> I already have spoken about my problem in this forum. I developed a Smart
> Device Application with a Login function. After the login function a
screen
> with some information is displayed for about five seconds and then be
> automatically forwarded to the next Form. I wrote a little code sample and
> wouuld ask if this is correct to solve my problem?
>
> using System.Drawing;
> using System.Collections;
> using System.Windows.Forms;
> using System.Data;
>
> namespace SmartDeviceApplication2
> {
>
> public class Form1 : System.Windows.Forms.Form
> {
> private System.Windows.Forms.TextBox textBox1;
> private System.Windows.Forms.Label label1;
> private System.Windows.Forms.Button button1;
> private System.Windows.Forms.Label label2;
> private System.Windows.Forms.MainMenu mainMenu1;
>
> private static AutoResetEvent evt;
> private static int count = 5;
>
> public Form1()
> {
>
> InitializeComponent();
>
>
> }
>
> protected override void Dispose( bool disposing )
> {
> base.Dispose( disposing );
> }
> #region Windows Form Designer generated code
>
>
> private void InitializeComponent()
> {
> this.mainMenu1 = new System.Windows.Forms.MainMenu();
> this.textBox1 = new System.Windows.Forms.TextBox();
> this.label1 = new System.Windows.Forms.Label();
> this.button1 = new System.Windows.Forms.Button();
> this.label2 = new System.Windows.Forms.Label();
> //
> // textBox1
> //
> this.textBox1.Location = new System.Drawing.Point(64, 64);
> this.textBox1.Text = "textBox1";
> //
> // label1
> //
> this.label1.Font = new System.Drawing.Font("Monotype Corsiva", 18F,
> System.Drawing.FontStyle.Italic);
> this.label1.ForeColor = System.Drawing.Color.LawnGreen;
> this.label1.Location = new System.Drawing.Point(16, 8);
> this.label1.Size = new System.Drawing.Size(160, 24);
> this.label1.Text = "Test";
> this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
> //
> // button1
> //
> this.button1.Location = new System.Drawing.Point(64, 136);
> this.button1.Text = "button1";
> this.button1.Click += new System.EventHandler(this.button1_Click);
> //
> // label2
> //
> this.label2.Location = new System.Drawing.Point(64, 104);
> this.label2.Text = "label2";
> //
> // Form1
> //
> this.BackColor = System.Drawing.Color.Orange;
> this.Controls.Add(this.label2);
> this.Controls.Add(this.button1);
> this.Controls.Add(this.label1);
> this.Controls.Add(this.textBox1);
> this.Menu = this.mainMenu1;
> this.Text = "Form1";
>
> }
> #endregion
>
> static void Main()
> {
> Application.Run(new Form1());
> evt = new AutoResetEvent(false);
> Timer t = new Timer(new TimerCallback(TimerCallback), null, 5000, 0);
> evt.WaitOne();
>
> ActiveForm = Form2;
>
>
>
> }
>
> private void button1_Click(object sender, System.EventArgs e)
> {
> label2.Text = textBox1.Text;
> tw.Write("This is the first message!");
> }
>
> private static void TimerCallback(object state)
> {
> evt.Set();
> }
> }
> }
>
> Thanks in Advance
>
> regards
>
> patrick