开发者

Setting a timer?

I'm uploading a file, all working fine, but I want to set a time for 60 seconds, so it waits for the开发者_C百科 file to upload before moving on.

Any ideas?


I agree with @Restuta, but without knowing more info:

Thread.Sleep(60000);

Documentation here.


This doesn't sound like the type of thing you would need a timer for unless your upload was happening on a thread?

If this is the case, as Abe Miessler says, just use Thread.Sleep(60000) on the thread you want to wait.

Otherwise, if it's all happening on one thread, your program will wait anyway, no need to make a timer, unless you wanted something where it waits up to 60 seconds and then times out if the upload wasn't successful after that much time?

In this case, you could make a timer that starts when the upload starts and stops either when the upload finishes or when sixty seconds have passed.


Waiting for a fixed amount of time is a bad idea.

The event you want to wait for is the file upload, so find a way to wait for that.

It could take 6, 60, or 6000 seconds, you have no way to know what the right number will be.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜