Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » using gates but program lags
using gates but program lags [message #17682] Mon, 25 August 2008 22:01 Go to next message
TeCNoYoTTa is currently offline  TeCNoYoTTa
Messages: 138
Registered: July 2008
Location: Egypt
Experienced Member

i call this function
String file_data = client.ExecuteRedirect(HttpClient::DEFAULT_MAX_REDIRECT, HttpClient::DEFAULT_RETRIES,THISBACK(progress_indecator));

and this is progress_indecator
bool Download_Manager_Window::progress_indecator(int x, int all)
{
	static float timer = 0;
	static float data = 0;
	static double counter = 0;
	double percentage;
	double temp1 = x, temp2 = all;
	if (all != 0)
		percentage = (temp1 / temp2) * 100.0;
	else
		percentage = 0;

	//label_DownloadDirectory.SetText(DblStr(percentage));

	progress_bar.Set(percentage, 100);

	timer = clock() - timer;

	data = x - data;

	//System("File path")
	//int percantage = (x/all)*100.0;

	if (data != 0 && timer != 0 && DblInt(counter) % 10 == 0)
	{
		//label_File.SetText(IntStr(x / 1000) + " KBs out of " + IntStr(all / 1000) + " KB ");
		int temp = data / timer;
		String temps = IntStr(temp);
		temps += " KB/S";
		label_DownloadSpeed.SetText(temps);
	}

	timer = clock();
	data = x;
	counter++;

	if (x == all && counter > 10)
	{
		timer = 0;
		data = 0;
		counter = 0;
		return true;
	}
	else
		return false;
}


but the program lags till the download finish

why ??
Re: using gates but program lags [message #17811 is a reply to message #17682] Fri, 29 August 2008 20:12 Go to previous message
amrein is currently offline  amrein
Messages: 209
Registered: August 2008
Location: France
Experienced Member
Because you are calling Download_Manager_Window::progress_iterator() too often from you main application? 0.5 or 1 second between each call should be enough.
Previous Topic: calling back a function after finishing a thread
Next Topic: non-blocking socket.Write("test string") crash on linux [BUG?]
Goto Forum:
  


Current Time: Thu Apr 18 22:29:58 CEST 2019

Total time taken to generate the page: 0.00706 seconds