"please wait" form
31.08.2009. u 07:46 · pre 208 meseci
#1
Pokusavam da napravim formu koja na sebi ima labelu sa tekstom "please wait" i koja bi se prikazivala dok program odradjuje neke stvari. Napravio sam klasu koja pokrece novi thread, a taj thread starta tu formu. Problem se javlja kada zelim da taj thread zaustavim, odnosno kada gasim wait formu. Greska: Exception has been thrown by the target of an invocation.
Evo klase:
Forma iz koje pozivam thread:
Nemam iskustva sa thread-ovima pa ako neko moze da pomogne.
Evo klase:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace BufferBoxApp
{
class Wait
{
Thread wt;
frmWait w;
public delegate void UgasiWait();
public Wait()
{
wt = new Thread(new ThreadStart(StartajWait));
wt.Priority = ThreadPriority.AboveNormal;
wt.Start();
}
void StartajWait()
{
w = new frmWait();
w.ShowDialog();
}
public void Ugasi()
{
w.Visible = false;
w.Close();
if (wt != null)
wt.Interrupt();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace BufferBoxApp
{
class Wait
{
Thread wt;
frmWait w;
public delegate void UgasiWait();
public Wait()
{
wt = new Thread(new ThreadStart(StartajWait));
wt.Priority = ThreadPriority.AboveNormal;
wt.Start();
}
void StartajWait()
{
w = new frmWait();
w.ShowDialog();
}
public void Ugasi()
{
w.Visible = false;
w.Close();
if (wt != null)
wt.Interrupt();
}
}
}
Forma iz koje pozivam thread:
Code:
void Filtriraj()
{
wait = new Wait();
... nesto se odradjuje oko 10 sec ...
BeginInvoke(new Wait.UgasiWait(wait.Ugasi));
wait = null;
}
void Filtriraj()
{
wait = new Wait();
... nesto se odradjuje oko 10 sec ...
BeginInvoke(new Wait.UgasiWait(wait.Ugasi));
wait = null;
}
Nemam iskustva sa thread-ovima pa ako neko moze da pomogne.
Potpis
SELECT * FROM หน่วยงานหลัก WHERE ยสันติ LIKE 'โดย%'
Re: "please wait" form