Hello,all: I am using ArcEngine(a software managing spatial data) to upload data(shapefile etc.) to database.Because the process of uploading data is time-consuming,when I click the ProgressBar window or minimize the parent window and then maximize the parent window,the parent window and the ProgressBar window is white using single thread. So,I use multithread to work out this prolem,and it does.But,the speed of uploading data to database slows down greatly . The work uploading data is no more than 10 minutes in single thread,but 40 minutes in multithread!! Who can help me?I appreciate your help!
private delegate bool UpdateHandle(int nValue,string text);
private UpdateHandle myUpdate = null;
myProcessBar is a Window has two controls,a ProgressBar named Bar and a Label named LabelInfo.It has a public method
BeeUpdate(int value, string text)
public bool BeeUpdate(int value, string text)
{
LabelInfo.Text = text;
LabelInfo.Refresh();
if (value > 0)
{
if (Bar.Value + value < Bar.Maximum)
{
Bar.Value += value;
Bar.Refresh();
return true;
}
else
{
Bar.Value = Bar.Maximum;
Bar.Refresh();
this.Close();
return false;
}
}
return false;
}
the delegate entry point:
private void ShowProcessBar()
{
myProcessBar = new ProgressBee("Uploading", 100 * ClassCount);
myUpdate = new UpdateHandle(myProcessBar.BeeUpdate);
myProcessBar.ShowDialog();
myProcessBar = null;
}
the method called by MainWindow
//caller is the main window
public bool CopyTo(parm1, parm2,Form caller)
{
MethodInvoker mi = new MethodInvoker(ShowProcessBar);
mi.BeginInvoke(null, null);
caller.BeginInvoke(mi);
Thread.Sleep(2000);
Thread copyProcess = new Thread(delegate()
{
for (int i = 0; i < FeatureClassCount; i++)
{
Thread.Sleep(30);
if (condition)
{
//the Interface of ArcEngine upload data
}
else
{
//another Interface of ArcEngine upload data
}
caller.Invoke(this.myUpdate, new object\[\] { 100, "……" });