Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Using timers help

Hello hf members, today I need some help using timers in vb.net. How will I go if I want something to run in a specific part of my code ?


Let me explain my self a little:

Code
Public Function Delete()
        If System.IO.File.Exists(Globals.Location) = True Then
            System.IO.File.Delete(Globals.Location)
        End If
    End Function

I'm running this function and than closing my program right away, but since vb.net is super fast the program does not have time to delete the file and still closes leaving the file untouched. I would like to set a time for that specific code to run than continue the application and close it. Pretty much pausing the program until the file gets deleted.

How would I go into doing that?
How about calling this in FormClosing() event?
File.Delete is a blocking call, so this isn't necessary. If the file remains untouched after your program terminates, you have other problems.

And by the way - you can omit the call to File.Exists. If you call File.Delete on a non-existing file, nothing will happen.
(Dec 11, 2016 03:52 PM)Dialog Wrote:  File.Delete is a blocking call, so this isn't necessary. If the file remains untouched after your program terminates, you have other problems.

And by the way - you can omit the call to File.Exists. If you call File.Delete on a non-existing file, nothing will happen.

What I meant by untouched was not deleted.. Also I check if the file is existing first before calling file.delete the file will be there anyways.
(Dec 11, 2016 04:09 PM)selfieman231 Wrote:  What I meant by untouched was not deleted.. Also I check if the file is existing first before calling file.delete the file will be there anyways.

Read my post again. I know what untouched means. And I know what File.Delete does.
(Dec 11, 2016 02:43 PM)Zilog80 Wrote:  How about calling this in FormClosing() event?

tried... but like I said vb.net is too fast... it does delete the file but I need the file for injection and inject doesnt happen because the file got deleted too fast. I need to put some type of timer after injection to delete the file. BUT after injection


Is there some way I can add a time to form.close() ? like a time before closing


Nope tried everything... There needs to be a way to add a timer anyone can help me?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bora or HyunaJan 27, 2020 12:26 PM 6 181 Jan 27, 2020 12:26 PM
Last Post: Lindros
[C#] by colja123Apr 3, 2016 01:47 AM 7 171 Apr 3, 2016 01:47 AM
Last Post: GuRuHaX
[.NET] by webwarlock72May 30, 2015 03:39 PM 4 119 May 30, 2015 03:39 PM
Last Post: paquiton96