1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 f = new Form1();
f.StartDelayed();
//Pour terminer le programme une fois la form disposée
f.Disposed += delegate { Application.ExitThread(); };
Application.Run();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
System.Timers.Timer m_myTimer;
public Form1()
{
InitializeComponent();
m_myTimer = new System.Timers.Timer(900000);
m_myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed);
m_myTimer.SynchronizingObject = this;
m_myTimer.AutoReset = false;
//Forcer la creation du handle, pour permettre l'invoke
this.CreateHandle(); /*ou appeler .Handle, ca reviens au meme*/
}
void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//Sur le tick, on active la form et on dispose le timer
this.Visible = true;
(sender as System.Timers.Timer).Dispose();
}
internal void StartDelayed()
{
m_myTimer.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
Application.Exit();
}
}
} |
Partager