|
Wonderful..Works great by this..Thanks to all others
Favourite quote:
In youth we learn, In age we understand.
|
|
|
|
|
As Ian has said above, you are updating your progress too often.
Progress is normally a percentage, so between 0 and 100. You are counting to 10million so you probably only need to report every 10000 iterations.
Also, if there is nothing else happening, the UI probably won't have time to update fully even then - if it hasn't got time to update then your users certainly won't have time to see it so the update is pointless!
|
|
|
|
|
Even when using the Background worker, I advice to make use of BeginInvoke methods to update the user interface elements. This has worked for me big time.
Create appropriate delegates for user interface updates and invoke them as and when necessary.
Sunil
|
|
|
|
|
Sunil,
In what way it has helped you more? Can you share your thoughts more please?
Favourite quote:
In youth we learn, In age we understand.
|
|
|
|
|
Hey munishk,
I had developed and application that created approximate of 20 Background workers. All these workers had to update progressbars embedded in a listview for around 20 listview items. However, initially the DoWork event handler used to update the UI which made the UI very sloppy and was sometimes showing a hung behavior. I changed the implementation to make use of Delegates to update the UI and by calling the BeginInvoke method this issue got resolved.
void delegate UpdateProgressDelegate(object params);
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
ArgumentClass backGroundCls = e.Argument as ArgumentClass;
int ctr=0;
do
{
ctr++;
UpdateProgressDelegate del = new UpdateProgressDelegate(UpdateProgress);
del.BeginInvoke(ctr, null, null);
} while (ctr < 10000000);
}
private void UpdateProgress(int ctr)
{
}
This should definitely work and solve your issue.
Sunil
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Testing_Trig
{
class Program
{
static void Main(string[] args)
{
Double Radian = (Math.PI / 180);
Double count = 0;
int[] array = {1,0};
for (int i = 0; i < 2; i++)
{
if (array[i] == 1) count += Math.Tan(Radian);
if (array[i] == 0) count += Math.Tan(-Radian);
}
Console.WriteLine("count = {0}", count);
}
}
}
|
|
|
|
|
Welcome to the world of floating point numbers and imprecise trigonometric approximations. I think it must be the latter that's responsible for this one, as the sign bit shouldn't affect how a floating point number gets rounded.
That said, I ran an equivalent of this and it seems to give 0 for me.
|
|
|
|
|
I don't understand why your compiler give "0" and mine gives -4. Explain why?
|
|
|
|
|
Can you tell which compiler your using and version number? This is really a blow to me. I never thought this could happen.
Thanks
|
|
|
|
|
I'm using Win 7 64 bit and I'm using an interpreted language running on .Net 2.0 or 3.5 (the core libraries are the same):
$Environment:Version
2.0.50727.4971
|
|
|
|
|
It doesn't give you -4. -4.06575814682064E-20 is shorthand for -4.06575814682064 x 10^-20, that's -0.0000000000000000000406575814682064, which is pretty close to 0.
|
|
|
|
|
How can I get the program to show me "0" instead of -4.06575814682064E-20? Thank You.
|
|
|
|
|
Generally with floating point checking for exact equality is a bad idea. You probably want to check if the result is within a certain distance from 0 instead, the exact amount depends on the precision you need. As for the output, you can format it[^] to display the way you want it to.
|
|
|
|
|
Exactly.
This is not a C# problem. This is a floating-point "deficiency", although the usefulness of such a tiny fraction may be nil.
Here are documents from a few other languages that may help illustrate the issue to the OP. I particularly recommend the Python one, which one can understand without knowing anything at all about Python.
Python: Python manual[^]
Perl: Perl Cookbook[^]
|
|
|
|
|
Look at the number again and note that it's in scientific notation.
You didn't get -4.something. You got -0.00000000000000000004, which is pretty close to 0.
|
|
|
|
|
|
Look again, that's -4 x 10^-20. That's extremely close to 0.
|
|
|
|
|
C&P gives me 0 on VS 2010 / Windows 7 x64.
|
|
|
|
|
Hi,
I have procedure which returns huge xml data in ref cursor from Oracle procedure,
When the procedure is executed in Toad, it works fine, But when my method calls the procedure it returns an empty row in the datatable.
any help would be appreciated.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
What does your method return in case of errors (e.g. timeout) - an empty row?
And what's the expected size of that xml string - GigaBytes? Then you ought to consider a different design.
|
|
|
|
|
it doesn't throws any errors, now I have changed and tried using a DataReader and that works. The XML contains more than 2000 lines and file size is just 83KB.
Somehow the DataReader can perform the operation, but the DataAdapter is not filling the datatable. Is there some kind of size limit?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
AB7771 wrote: Is there some kind of size limit?
There are always size limits.
You might try slightly below 64k if you are interested. If that doesn't work then try 32k, etc.
|
|
|
|
|
How can I display everything at both the console and a txt file.
|
|
|
|
|
Replace your Console.Write and Console.WriteLine calls with a calls to your own method - it can then call the appropriate Console and file system methods.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hello Everyone,
I would like to create my own barcode generator without using third party library.can i get some info on it?
|
|
|
|