private async void btnCreateFile_Click(object sender, EventArgs e) { FrequencyGenerator fg = new FrequencyGenerator(); Stopwatch watch = new Stopwatch(); lblStatus.Text = "Calculating Frequencies..."; watch.Start(); await Task.Run(() => fg.GenerateFromImage(ImageData.ImageMatrix)); lblStatus.Text = "Constructing Tree..."; HuffmanTree tree = new HuffmanTree(fg); await Task.Run(() => tree.ConstructTree()); BinaryFile file = new BinaryFile(ImageData.ImageMatrix, ImageData.InitialSeed, ImageData.TapPosition, ImageData.Width, ImageData.Height, ImageData.NumberOfBits, tree); lblStatus.Text = "Creating Binary File."; await Task.Run(() => file.Create(txtFileName.Text)); watch.Stop(); lblStatus.Text = "Binary File Created."; lblTimeTaken.Visible = true; string te = watch.Elapsed.ToString(@"m\:ss"); lblTimeTaken.Text = te; }