I'm downloading a texture from a server. Running the code in the editor takes a few second to download it. But when I build it and run the .exe the download takes multiple minutes. Is there a reason for it? Any build option?
HttpWebRequest request = WebRequest.CreateHttp(PATH);
WebResponse response = await request.GetResponseAsync();
Stream stream = response.GetResponseStream();
byte[] data = new byte[response.ContentLength];
int bytesRead = 0, count = (int)response.ContentLength;
while (bytesRead < count) {
int read = await stream.ReadAsync(data, bytesRead, count - bytesRead);
if (read <= 0)
continue;
bytesRead += read;
}
EDIT:
The Problem is awaiting. Awaiting Stream.Read called in Task.Factory.StartNew results in the same behavior. Values from Task Manager Ethernet Profiling:
Async: Editor: 47Mbps; Build 4.4Mbps
Sync: Editor = Build: 61Mbps