|
Try this:
private int contrast = 0;
private void timer1_Tick(object sender, EventArgs e)
{
if (contrast > -128)
{
contrast--;
}
else
{
timer1.Stop();
}
}
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Hi,
having the loop execute completely within a single timer tick won't cut it; what you need is one tiny step on each of a number of timer ticks, as Griff already has shown.
FYI: that requires a small time step, probably pretty close to what your system is willing to offer through a System.Windows.Forms.Timer; see my article Timer surprises, and how to avoid them[^]
BTW: your for loop's exit condition was wrong too.
|
|
|
|
|
|
The problem is quite simple, but you need to do some thinking (and possibly studying) because it shows that you have not understood static versus instance data.
public string _variable = String.Empty;
Declares a string variable called _variable, and assigns it to empty. Because this has no prefix, this is an instance variable. I.e. it is part of your class, and each instance of the calls has a separate copy of the variable. If this were cars, it could be the Colour - your car has a different Colour from my car.
public static string Variable
{
set { _variable = value; }
get { return _variable; }
}
Declares a string property called Variable. Because this has the static prefix, this is a static variable. I.e. it is part of your class, but all instances of your class share the same value. If this were cars, it could be CountTheWheels - your car and my car always have the same number of wheels - four.
Because the property is static, and the variable it is trying to use is instance, the compiler is telling you that you need to refer to a specific instance of your class in order to access the _variable value you want. What you are trying to ask is "What colour is any car?" - which is plainly nonsense since all cars do not have the same colour.
BTW: Do not make the _variable field public - that is what the property is for. If you expose the property and the backing field, which one is the user supposed to work with? The field? The property? Both? What if the property does something with the data before assigning it to the field - like validation?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
"Message Removed"
I really hate it when they do that.
|
|
|
|
|
Unfortunately one can not even respond any longer, there is a reply widget but it fails.
The message was:
Hey guys, I know this is simple stuff still would appreciate ur help, I assumed by declaring this method static It would solve the problem but hasn't ... Frown
I get this error: An object reference is required for the non-static field, method, or property
public string _variable = String.Empty;
public static string Variable
{
set { _variable = value; }
get { return _variable; }
}
|
|
|
|
|
So, he deletes the message to save himself the embarrassment, and you put it straight back?
You're a cruel man, Luc!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
All I did was restore the value of your reply, which had become pointless when the question disappeared.
I also informed the OP of his bad manners using different means.
FWIW: why is the reply widget present, when replying to a removed message does not work??
|
|
|
|
|
|
|
it is much easier to install a little bot that copies new messages as soon as they appear...
|
|
|
|
|
Message removed, to preserve the removed content of the removed message. Which was removed at the request of a different, removed message.
Should I remove this message, just to be safe?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
|
one should not reveal this. please remove your reply immediately!
|
|
|
|
|
|
I am still waiting...
BTW: now there's two of them to remove.
|
|
|
|
|
Please consider the previous message removed
|
|
|
|
|
<whisper>It's ok - I removed my response, quoting his removed message.</whisper>
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
message to all: now see how removing a question turns a thread into a mysterious sequence of sentences with a rather high level of probable offtopicness.
|
|
|
|
|
In C#, is there a simple way to resume an download over http, transparantly?
For example, i call a function to download a file x to drive c:. In the middle of the operation, I close the downloading program. The program would abort the transfer, but not delete the partially downladed file x.
I start the program, and once again call the function to download the same file x to driver c:. The function would realize that there is already a part of file x present on drive c: and then resume the download.
Can any one help me???
Thanking U,
Sunil G.
modified on Saturday, May 1, 2010 4:38 AM
|
|
|
|
|
Use the DownloadDataAsync method of the WebClient class to download files from a server.
|
|
|
|
|
Using WebClient you can download your file synchronously as well as asynchronously.
Download File Synchronously
using System.Net;
WebClient webClient = new WebClient();
webClient.DownloadFile("http://mysite.com/myfile.txt", @"c:\myfile.txt");
Download File Asynchronously
private void btnDownload_Click(object sender, EventArgs e)
{
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri("http://mysite.com/myfile.txt"), @"c:\myfile.txt");
}
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBar.Value = e.ProgressPercentage;
}
private void Completed(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("Download completed!");
}
Hope this will help!
Jinal Desai - LIVE
|
|
|
|
|
Madam I think u didnt get my point.
For example, I call a function to download a file x to drive c:. In the middle of the operation, I close the downloading program. The program would abort the transfer, but not delete the partially downladed file x.
I start the program, and once again call the function to download the same file x to driver c:. The function would realize that there is already a part of file x present on drive c: and then resume the download.
Thanking You,
Sunil G.
|
|
|
|
|
|
The HttpWebRequest. AddRange() [^] method allows you to resume downloading from a specific point.
/ravi
|
|
|
|