Skip to content

Instantly share code, notes, and snippets.

@hawksprite
Created June 28, 2014 03:51
Show Gist options
  • Save hawksprite/2b83bec62f4f9416b1b0 to your computer and use it in GitHub Desktop.
Save hawksprite/2b83bec62f4f9416b1b0 to your computer and use it in GitHub Desktop.
private Thread downloadFileThread;
void DownloadDatFile()
{
// The class is inherinty async so you don't need to put it in a thread, but if you want to monitor the progress
// in a "Snappy" manor in something like unity without worrying about the possible frame cap to disrupt thing from the Update callback
// then just use this setup to monitor it with a standard .NET thread
downloadFileThread = new Thread(new ThreadStart(threadDownloadDatFile));
downloadFileThread.Start();
}
void threadDownloadDatFile()
{
Downloader downloader = new Downloader();
downloader.Start("http://google.com", "index.html");
while (!downloader.Finished)
{
// Progress check
float progress = downloader.Progress; // 0.0 - 1.0
int progressPercent = downloader.Progress_Percent; // 0 - 100
}
// All unfinished!
// Need to now unzip?
downloader.Unzip();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment