Jump to content
  • Advertisement
Sign in to follow this  
DrGUI

[.net] Background File Verification

This topic is 4489 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I think it would take too long to make my own game file system using zip files or something, so I'm considering background verification of game files. I know it's pointless trying to stop really serious people but I'm sure this will stop 99% of people and give me some more experience with multithreading. The verification would be on a separate thread so I can make it sleep, as I obviously don't want it hogging half the CPU and slowing my game down. Pseudo code for my thread procedure would be something like this:
Get file path from main thread
Open the file to verify
while (bytes left to be read)
{
   Get whether app is closing, exit this thread (return) if it is (after closing file)
   Compute some simple checksum with the bytes, just xoring them maybe
   Sleep for 50ms or so...need to find a good value for this
}
Send checksum back to main thread (where it will be compared to what it should be), or an exception if one occured
Now I've done some asynchronous file IO in the past, apart from that I haven't really done any multithreading, though I know about the race condition and deadlocking. I'm obviously fine with opening the file and the checksum, I'm just not sure about the interaction of the threads. Would I just have a class with properties and methods that use 'lock(this)' to make them thread-safe? Thanks a bunch; I hope that's coherent, I need to go do more school work :(

Share this post


Link to post
Share on other sites
Advertisement
Also, is there anything I can do if my verification thread is blocked on IO and I want to end it immediately, for instance if the app is closing down?
From using Thread.Abort would the ThreadAbort exception raised allow me to close the file before returning?

Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!