/// <summary> /// show the progressbar and hide the refresh button /// </summary> private void ShowProgressBar() { //test whether Invoke is required (was this call made on a different thread than the main thread?) if (this.lstWeatherItemNames.InvokeRequired) { //call itself on the main thread ShowProgressBarCallBack d = new ShowProgressBarCallBack(ShowProgressBar); this.Invoke(d); } else { //clear all the rows from the table m_weatherItemsTable.Rows.Clear(); //clear all the items of the listbox lstWeatherItemNames.Items.Clear(); //set the progressbar properties int count = m_cityNames.Length; progressBar1.Maximum = count; progressBar1.Value = 0; btnRefreshList.Visible = false; progressBar1.Visible = true; } }
public void ShowProgressBar(bool showProgressBar) { if (progressBar1.InvokeRequired) { var d = new ShowProgressBarCallBack(ShowProgressBar); try { Invoke(d, showProgressBar); } catch { // ignored } } else { try { progressBar1.Visible = false; } catch { // ignored } } }
/// <summary> /// hide the progressbar and show the refresh button /// </summary> private void HideProgressBar() { //test whether Invoke is required (was this call made on a different thread than the main thread?) if (this.progressBar1.InvokeRequired) { //call itself on the main thread ShowProgressBarCallBack d = new ShowProgressBarCallBack(HideProgressBar); this.Invoke(d); } else { //set the visibility btnRefreshList.Visible = true; progressBar1.Visible = false; } }