|
Oh, I hadn't seen this reply of yours until now.
I would add that, if (1+totalBytesToRead/100) doesn't vary, it can be calculated once rather than repeatedly:
int divisor = totalBytesToRead/100 ;
if ( divisor == 0 ) divisor = 1 ;
But as long as you're making a local variable to hold it, why not use a float (only two decimal places are required) and be done with it?
float divisor = totalBytesToRead/100.0F ;
|
|
|
|
|
PIEBALDconsult wrote: why not use a float
because I am always hesitant to introduce reals when the end result I'm after is an integer.
But it would be all right here.
And now this begs the question: why is BackgroundWorker.ReportProgress() taking an int, as progress really is something that goes from 0.0 to 1.0?
and why is ScrollBar.Value an int? One often regrets it isn't either long or some real.
Maybe they too don't want to force reals on you when your app is all integer.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
No idea. I also want NumericUpDown to be available with different types: NumericUpDown<int> or something.
Luc Pattyn wrote: progress really is something that goes from 0.0 to 1.0?
Well, can't it also go 0 to 54444964 ? And let .net handle the math?
|
|
|
|
|
You are the only one who hit the nail in its head
|
|
|
|
|
I'm a hammer at times.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Anyway, I'm using ulong now, and I'm not calculating the years when a HDD will be made to overflow it.
BTW : Are you sure about your message title ? I thought we were friends
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen W.K. wrote: Are you sure about your message title ?
I think so. It started with a false accusation and then took more than 20 messages to get to the root cause. Hasn't anyone seen overflows before?
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Luc Pattyn wrote: It started with a false accusation
oh...your title have also false accusation. The Math is right, but int is unable to hold the value
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Wait a minute... Set the ProgressBar's Maximum to 54444964, set the Value to 36257792 (or whatever) and let the PB handle the math; it's going to anyway, you're just duplicating effort.
|
|
|
|
|
Hold your horses.
In a few days/weeks/years, when the app starts dealing with really large files, with sizes that exceed Int32.MaxValue, the size variables will need to be Int64 all the way, and the PB cannot handle those anyway.
FWIW: what I tend to do is turn file sizes into kilobytes and ints, which "limits" them to 2TB (which is much larger than my largest partition).
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
We'll burn that bridge after we've crossed it.
Besides the OP's code is using ints and it doesn't say anything about files; just using ints and a ProgressBar.
|
|
|
|
|
Hello, i have a default program .resx file it is named: form1.resx, i'd like to do allow change users the string value, i have 'First' string and it's value is 'One', i'm using this code to load the string from it:
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
rValue = resources.GetString("First");
And it get's 'One' value, it's correct. So i'd like to change it by a program. I've tried
resources.ApplyResources("First", "Two"); but it won't work, any ideas? Thanks.
|
|
|
|
|
String resources are compiled into string tables in the assembly. They are readonly and cannot be changed. If you wish to change strings at runtime, use custom settings file.
|
|
|
|
|
Thought I would share what I learned yeasterday. Maybe some folks might enjoy my pain.
I setup a text change event to exit a text box when the 17th character was entered. I automatically looks up a record in the database. The problem was the text box fired 4 times after the last character was entered.
I spent two hours tryinig to figure this out. I finally reached out to my teamates. Here is what I did.
When I built the form I added the text changed event to a textbox. I then "copied" the text box to several other text boxes (you guested it 3 other boxes).
Because the copy carried the rerefence to
Maybe this is a "newbee" mistake, but thought I would share.
Rudy
Somewhere between the grey (making sausage out of business rules) and the abstract (what is known and what is achieved) exists clarity and certainty.
|
|
|
|
|
Rudy Steinhoff wrote: I spent two hours tryinig to figure this out.
This is the biggest newbie mistake in this. After about 30 minutes you should have been asking for help.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You are right, thanks for pointing out my mistake. Its good to get this kind of feedback. It makes me want to post to this forum again.
|
|
|
|
|
No I do think, that trying to get a solution at your own is a better practice for a newbie.
If everybody would do the same, as the poster did, and uses some brain or at least google, then
there were not such a mass of users querying stupid questions in here!
If someone succeeds in querying for help, every time he spent more then 10 minutes on a problem
without solution, why should she/he learn how to solve problems on her/his own if he/she can ask someone?
Greetings
Covean
|
|
|
|
|
Mark was being ironic. He's dealt with so many people that post as soon as they hit a problem, that having somebody like this was a refreshing change.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Oh thanks for this information, I misunderstood him respectively not seen the ironic in it.
Greetings
Covean
|
|
|
|
|
I wasn't being ironic, but yes it was a refreshing change of post.
Yes it is important to learn, however, learning also means knowing what resources you have available. From a project management perspective I'd be a little ticked off that he spent two hours struggling with something when help was available.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I'll disagree with your disagreement.
From a project management perspective I'd be a little ticked off that he spent two hours struggling with something when help was available.
Knowing what resources are available is also part of learning, Google isn't the only source.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Ok and how many developer you met in your life working on your projects and asking for "How can I retrieve something from database?" or "How to open a window or retrieve form data?"
There is a big difference between project work and learning!
For someone who learns how to develop something its really
a better practice to find the problem and the solution for his own!
If you work on a project, I would assume that you can develop, know the important issues and the technics, how to go on problems and solve it. So I really would kick as...es if someone idles on a problem and does not say anything, but the time runs.
Google isn't the only source.
There you are right, but I really often read some questions here, where I only have to type 2 words in
google and I will find a solution. But of course, querying someone else and be lazy is simpler!
If you meant me with the "google"-thing. So I only have to say I taught myself how to develop programs,
spent hours for hours trying to achieve my own goal (to a time where the internet was in diapers ).
Knowing what resources are available is also part of learning
This is also right.
But here is something I said before:
If someone succeeds in querying for help, every time he spent more then 10 minutes on a problem
without solution, why should she/he learn how to solve problems on her/his own if he/she can ask someone?
So if your best source is somebody you can call guru, and query him every time, whats the reason,
to learn it on your own? (This applies very often to "newbee"s, who wants to achieve a goal that
doesn't match with their own skills.)
Finally:
Sometimes its better not to help somebody, cause it strengthen its skills!
Greetings
Covean
|
|
|
|
|
Covean wrote: So if your best source is somebody you can call guru, and query him every time, whats the reason,
to learn it on your own? (This applies very often to "newbee"s, who wants to achieve a goal that
doesn't match with their own skills.)
You are missing the point. The OP was not in a learning environment, he/she had co-workers available and eventually asked for their help; just waited much too long to do so.
If one is constantly asking for help and not doing at least something on their own, thats one thing. If they attempt it, realize they don't know, then ask for help, that is learning.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Ok maybe you are right in the fact that he waited too long.
(Didn't realize that he wasn't in a learning environment.)
But what does "realize they don't know" really mean.
Not to know how to start? Or not to know how to solve
the last 20% of a problem? At what stage should somebody
realize he/she will fail with his/her attempt?
At least the last question is hard to answer.
I will not disagree with the fact that this is learning,
but there are many ways to learn something and the best
way to do so is learning by your own faults.
Greetings
Covean
|
|
|
|
|
Ok, so I have been trawling the web to try and find an answer to this, but to no avail.
Basically, I have a DirectShow filter (well 2) which will allow me to configure a Hauppage WinTV USB adapter (though I doubt the specific filter is 100% relevant to answer the question) to use PAL (I) and to set the source as Composite In. So far, I have found ways to display a filter's property page, and to change the settings of a DMO filter, but not enumerate and change the properties of a non DMO source filter.
The reason for needing to do this is that both filter options seem to reset with Windows, meaning that our source becomes NTSC and Tuner In, rather than Pal-I and Composite In. The filters are classed as a Video Capture Source (WinTV HVR-900H Capture) and a WDM Streaming Crossbar Device (WinTV HVR-900H Crossbar), but the ability to change any property of any filter sans a GUI will be a step in the right direction
I am using a .Net wrapper to play with the filter graph through c#, but have limited knowledge of COM interop (thus the wrapper).
What's the easiest method to go about this?
|
|
|
|