[Gtk-sharp-list] Issue with Mono/GTK# app after threading (NewB)
John Meadows
john at meadowsonline.com
Tue Jul 12 05:44:22 EDT 2005
I am working on my first application written in Gnome/GTK# and mono
1.1.8 / Monodevelop; and I have run into an issue (if this is a NewB
issue, I apologize in advance).
This application has a couple of methods that are run via threads
(basically for filecopying, as my app. is a utility for managing MP3
files on my MP3 player), and I have tried to use the examples I have
seen online. Everything seems to work OK, but after I run one of these
threaded methods the first time I see one of the following issues:
1. If I display a FileSelection widget it comes up, but the text inside
the widget (the list of files basically) is not visible, even though it
appears to be there (as I have some debug code that fires off a line to
the console whenever a file is selected, so I think something is there
even if it is not displaying)
2. The main window of my application also uses a Treeview control. In a
manner similar to #1 above, after running one of my threaded methods
once, if I run a method to populate the treeview, neither the column
headings or the test for the items in the Treeview appear (although
again I have debug code writing to the console that shows there are
items in the Treeview; it's just the text that is not appearing properly).
I am not sure where to go with this from a debugging point of view. I
have put some sample code below, as maybe the issue is there, but I
don't know, and of course I did not want to post everything. Is there
some other refresh I need to call?
Any suggestions on what to try would be most appreciated!! Thanks in
advance!
Here's some code
//copy single file to player
void CopyFileToPlayer (object sender, EventArgs a)
{
clearLabel(); // resets status labels on window
lblStatus.Text = "File Copying in Progress...";
buttonCopySingle.Sensitive = false;
Thread oThread = new Thread(new ThreadStart(runSingleCopyThread));
oThread.Start();
notify = new ThreadNotify (new ReadyEvent (ready));
while (!oThread.IsAlive);
}
the method above calls:
//copy single file from playlist to player
private void runSingleCopyThread()
{
fc = new FileCommands(); //this is an assembly use for copying
the MP3 files
lblStatus.Text = "File Copying in Progress...";
fc.currentTrackFile = currentTrack;
fc.mp3PlayerPath = txtPlayerPath.Text +
System.IO.Path.DirectorySeparatorChar.ToString();
fc.copyFile();
if(fc.oppStatus != "Copying Files...")
{
lblStatus.Text = fc.oppStatus;
}
notify.WakeupMain ();
}
The notification method is:
//called when file copying threads are done
void ready ()
{
buttonCopy.Sensitive = true;
buttonCopySingle.Sensitive = true;
lblStatus.Text = fc.oppStatus + ": " + fc.fileCopyCount + "
file(s) Copied";
this.ShowAll();
}
More information about the Gtk-sharp-list
mailing list