Click here to Skip to main content
15,896,118 members
Home / Discussions / C#
   

C#

 
AnswerRe: Localization Pin
Paul Conrad21-Jul-07 6:26
professionalPaul Conrad21-Jul-07 6:26 
AnswerRe: Localization Pin
DavidNohejl21-Jul-07 9:53
DavidNohejl21-Jul-07 9:53 
QuestionThread, WaitSleepJoin Pin
Johan Martensson21-Jul-07 5:59
Johan Martensson21-Jul-07 5:59 
AnswerRe: Thread, WaitSleepJoin Pin
Luc Pattyn21-Jul-07 6:22
sitebuilderLuc Pattyn21-Jul-07 6:22 
GeneralRe: Thread, WaitSleepJoin Pin
Johan Martensson21-Jul-07 6:54
Johan Martensson21-Jul-07 6:54 
GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn21-Jul-07 7:13
sitebuilderLuc Pattyn21-Jul-07 7:13 
GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn21-Jul-07 7:28
sitebuilderLuc Pattyn21-Jul-07 7:28 
GeneralRe: Thread, WaitSleepJoin Pin
Johan Martensson21-Jul-07 7:49
Johan Martensson21-Jul-07 7:49 
I will look into your suggestions, they look very interesting.
The download-methods in the download class looks like this:

<br />
        public void DownloadFile(string outPath)<br />
        {<br />
            outFile = outPath;<br />
            // Create a new thread that calls the StartDownload() method<br />
            thrDownload = new Thread(StartDownload);<br />
            // Start the thread, and thus call StartDownload()<br />
            thrDownload.Start();<br />
        }<br />
<br />
private void StartDownload()<br />
        {<br />
            try<br />
            {<br />
                // Create a request to the file we are downloading<br />
                webRequest = (HttpWebRequest)WebRequest.Create(dowloadUrl);<br />
                // Set the proxy to use if any<br />
                if (!dowloadProxy.Equals(string.Empty))<br />
                    webRequest.Proxy = new WebProxy(dowloadProxy);<br />
                // Set the startingpoint of the stream if any and resume is aloud<br />
                //if (startPoint > 0 && resumeIsAloud)<br />
                //    webRequest.AddRange(startPoint);<br />
<br />
                if(endOffset>0)<br />
                 webRequest.AddRange(startOffset, endOffset);<br />
                else<br />
                 webRequest.AddRange(startOffset);<br />
<br />
                // Set default authentication for retrieving the file<br />
                webRequest.Credentials = CredentialCache.DefaultCredentials;<br />
                // Retrieve the response from the server<br />
                webResponse = (HttpWebResponse)webRequest.GetResponse();<br />
                //Ask the server for the file size and store it<br />
                fileSize = webResponse.ContentLength;<br />
                // Get the response-stream<br />
                strResponse = webResponse.GetResponseStream();<br />
<br />
                // Set the output-stream<br />
                strLocal = new FileStream(outFile, FileMode.Create, FileAccess.Write, FileShare.None);<br />
<br />
                // It will store the current number of bytes we retrieved from the server<br />
                int bytesSize;<br />
                // A buffer for storing and writing the data retrieved from the server<br />
                byte[] downBuffer = new byte[2048];<br />
<br />
                // Set the start-time<br />
                downStart = DateTime.Now;<br />
<br />
                // Loop through the buffer until the buffer is empty<br />
                while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)<br />
                {<br />
                    // Write the data from the buffer to the local hard drive<br />
                    strLocal.Write(downBuffer, 0, bytesSize);<br />
                    CalculateDownloadingInfo();<br />
                }<br />
            }<br />
            catch (Exception e)<br />
            {<br />
                lastError = e;<br />
                RaiseDownloadError(e);<br />
            }<br />
            finally<br />
            {<br />
                if (strResponse != null) strResponse.Close();<br />
                if (strLocal != null) strLocal.Close();<br />
                if (thrDownload != null) thrDownload.Abort();<br />
            }<br />
        }<br />

GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn21-Jul-07 8:18
sitebuilderLuc Pattyn21-Jul-07 8:18 
GeneralRe: Thread, WaitSleepJoin Pin
Johan Martensson21-Jul-07 9:18
Johan Martensson21-Jul-07 9:18 
GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn21-Jul-07 9:54
sitebuilderLuc Pattyn21-Jul-07 9:54 
GeneralRe: Thread, WaitSleepJoin Pin
Johan Martensson21-Jul-07 10:39
Johan Martensson21-Jul-07 10:39 
GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn21-Jul-07 11:03
sitebuilderLuc Pattyn21-Jul-07 11:03 
GeneralRe: Thread, WaitSleepJoin Pin
Johan Martensson21-Jul-07 11:32
Johan Martensson21-Jul-07 11:32 
GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn21-Jul-07 11:51
sitebuilderLuc Pattyn21-Jul-07 11:51 
GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn21-Jul-07 13:08
sitebuilderLuc Pattyn21-Jul-07 13:08 
GeneralRe: Thread, WaitSleepJoin Pin
Johan Martensson21-Jul-07 22:14
Johan Martensson21-Jul-07 22:14 
GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn22-Jul-07 0:34
sitebuilderLuc Pattyn22-Jul-07 0:34 
GeneralRe: Thread, WaitSleepJoin Pin
Johan Martensson24-Jul-07 0:15
Johan Martensson24-Jul-07 0:15 
GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn24-Jul-07 1:01
sitebuilderLuc Pattyn24-Jul-07 1:01 
GeneralRe: Thread, WaitSleepJoin Pin
Johan Martensson24-Jul-07 8:21
Johan Martensson24-Jul-07 8:21 
GeneralRe: Thread, WaitSleepJoin Pin
Luc Pattyn24-Jul-07 11:54
sitebuilderLuc Pattyn24-Jul-07 11:54 
QuestionDataSource binding problem Pin
~~~Johnny~~~21-Jul-07 3:27
~~~Johnny~~~21-Jul-07 3:27 
AnswerRe: DataSource binding problem Pin
~~~Johnny~~~21-Jul-07 5:01
~~~Johnny~~~21-Jul-07 5:01 
GeneralRe: DataSource binding problem Pin
Urs Enzler22-Jul-07 6:24
Urs Enzler22-Jul-07 6:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.