I have a such code: http://pastie.org/1638879
I got it from someone’s blog. It must sort big files.
I preform it in separated thread:
protected virtual void goButton_Clicked (object sender, System.EventArgs e)
{
FileSort fileSort = new FileSort(fileNameEntry.Text, "./BigFileSorted.dat");
fileSort.SplitProgressChanged += fileSortProgressSplitting;
fileSort.SortChunksProgressChanged += fileSortProgressSorting;
fileSort.MergeProgressChanged += fileSortProgressMerging;
Thread thread = new Thread(fileSort.Sort);
thread.Start();
//fileSort.Sort();
}
protected virtual void fileSortProgressSplitting(FileSort o, double progress)
{
progressBar.Fraction = progress;
progressBar.Text = "Splitting...";
}
protected virtual void fileSortProgressSorting(FileSort o, double progress)
{
progressBar.Fraction = progress;
progressBar.Text = "Sorting...";
}
protected virtual void fileSortProgressMerging(FileSort o, double progress)
{
progressBar.Fraction = progress;
progressBar.Text = "Merging...";
}
For small files everything is normally, but for big files(about 4 gb), progressBar stops on some value for some reason during the splitting step. But splitting was finished. What is reason of this stranges?
P.S. I’m writing it on Mono and Gtk#.
Like winforms, Gtk has thread affinity. Your updates should happen on the main UI loop. You can do this via:
See also the mono Best Practices notes on this.