N
nullmind
Hi everyone,
I've got myself a C# .NET 1.1 application I'm making where a docked
Panel that contains some progress bars etc. is being toggled between
Visible and not. Basically a user drags some photos into the window and
it activates a background thread that shows the panel, does some work,
and hides it again. If this is not in a separate thread, it works! I've
tried doing a manual Update(), and PerformLayout() calls, but nothing
works. The thread work happens, but the panel never shows. I've also
tried Application.DoEvents().
private void itemImages_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e) {
ArrayList formats = new ArrayList(e.Data.GetFormats());
if(formats.Contains(DataFormats.FileDrop)){
//imageImportFiles =
(string[])e.Data.GetData(DataFormats.FileDrop);
imageImportFiles.Clear();
imageImportFiles.AddRange((string[])e.Data.GetData(DataFormats.FileDrop));
imageImportThread = new Thread(new ThreadStart(this.importImages));
imageImportThread.Start();
}
}
private void importImages(){
imageImportPanel.Visible = true;
imageLoadProgress.Maximum = imageImportFiles.Count;
imageLoadProgress.Value = 0;
ArrayList imageFiles = new ArrayList();
foreach(string filePath in imageImportFiles){
importDirectory(filePath, imageFiles);
}
imageLoadProgress.Maximum = imageFiles.Count;
imageLoadProgress.Value = 0;
foreach(string filePath in imageFiles){
string label = getFileName(filePath);
Image img;
int imgId;
ListViewItem item;
imageImportStatus.Text = String.Format("Importing {0}... ({1} of
{2})",
label, imageLoadProgress.Value+1, imageLoadProgress.Maximum);
Application.DoEvents();
try{
img = Image.FromFile(filePath);
}catch(Exception){
continue;
}
imgId = itemImageList.Images.Add(img, Color.Transparent);
item = itemImages.Items.Add(label, imgId);
imageLoadProgress.Value++;
}
imageImportPanel.Visible = false;
}
I've got myself a C# .NET 1.1 application I'm making where a docked
Panel that contains some progress bars etc. is being toggled between
Visible and not. Basically a user drags some photos into the window and
it activates a background thread that shows the panel, does some work,
and hides it again. If this is not in a separate thread, it works! I've
tried doing a manual Update(), and PerformLayout() calls, but nothing
works. The thread work happens, but the panel never shows. I've also
tried Application.DoEvents().
private void itemImages_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e) {
ArrayList formats = new ArrayList(e.Data.GetFormats());
if(formats.Contains(DataFormats.FileDrop)){
//imageImportFiles =
(string[])e.Data.GetData(DataFormats.FileDrop);
imageImportFiles.Clear();
imageImportFiles.AddRange((string[])e.Data.GetData(DataFormats.FileDrop));
imageImportThread = new Thread(new ThreadStart(this.importImages));
imageImportThread.Start();
}
}
private void importImages(){
imageImportPanel.Visible = true;
imageLoadProgress.Maximum = imageImportFiles.Count;
imageLoadProgress.Value = 0;
ArrayList imageFiles = new ArrayList();
foreach(string filePath in imageImportFiles){
importDirectory(filePath, imageFiles);
}
imageLoadProgress.Maximum = imageFiles.Count;
imageLoadProgress.Value = 0;
foreach(string filePath in imageFiles){
string label = getFileName(filePath);
Image img;
int imgId;
ListViewItem item;
imageImportStatus.Text = String.Format("Importing {0}... ({1} of
{2})",
label, imageLoadProgress.Value+1, imageLoadProgress.Maximum);
Application.DoEvents();
try{
img = Image.FromFile(filePath);
}catch(Exception){
continue;
}
imgId = itemImageList.Images.Add(img, Color.Transparent);
item = itemImages.Items.Add(label, imgId);
imageLoadProgress.Value++;
}
imageImportPanel.Visible = false;
}