private void Form2_Load(object sender, EventArgs e)
{
con1.Open();
Form1 home = new Form1();
home.MdiParent = this.MdiParent ;
System.Timers.Timer timer1 = new System.Timers.Timer();
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyComputer) + @"\\server1\KamalSingh\ScreenCaptures");
t.Interval = 500;
t.Tick += new EventHandler(StartThread);
t.Start();
}
System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
//Thread tt;
private static Bitmap bmpscreenshot;
private static Graphics gfxscreenshot;
void TakeScreenShot()
{
bmpscreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height,PixelFormat.Format32bppArgb);
gfxscreenshot = Graphics.FromImage(bmpscreenshot );
gfxscreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,Screen.PrimaryScreen.Bounds.Y,0,0,Screen.PrimaryScreen.Bounds.Size,CopyPixelOperation.SourceCopy );
bmpscreenshot.Save(Environment.GetFolderPath(Environment.SpecialFolder.MyComputer) +@"\\server1\KamalSingh\ScreenCaptures\.bmp", ImageFormat.Png);
// tt.Abort();
}
protected void StartThread(object sender, EventArgs e)
{
Thread th = new Thread(new ThreadStart(TakeScreenShot));
th.SetApartmentState(ApartmentState.STA );
th.Start();
Thread.Sleep(100);
th.Join();
}
プログラムの実行中に発生するこのエラーを修正したいと思います。エラーはしばらくすると発生します。