File tree 1 file changed +5
-6
lines changed
Runtime/Scripts/Core/Request
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections ;
3
3
using System . Collections . Generic ;
4
+ using System . Diagnostics ;
4
5
using System . Text ;
5
6
using System . Threading ;
6
7
using System . Threading . Tasks ;
@@ -134,8 +135,8 @@ private async Task RequestRoutineAsync(CancellationToken cancellationToken)
134
135
var operation = _request . SendWebRequest ( ) ;
135
136
}
136
137
137
- float requestProgress = - 1f ;
138
- float requestStuckTime = 0f ;
138
+ float requestProgress = - 1f ;
139
+ Stopwatch requestStuckTime = Stopwatch . StartNew ( ) ;
139
140
140
141
while ( ! _request . isDone )
141
142
{
@@ -145,9 +146,7 @@ private async Task RequestRoutineAsync(CancellationToken cancellationToken)
145
146
146
147
if ( requestNotProgressing )
147
148
{
148
- requestStuckTime += Time . deltaTime ;
149
-
150
- if ( requestStuckTime >= _requestTimeOutDuration )
149
+ if ( requestStuckTime . Elapsed . TotalSeconds >= _requestTimeOutDuration )
151
150
{
152
151
RequestState = WebRequestState . Timeout ;
153
152
HandleOnRequestTimeOut ( ) ;
@@ -157,7 +156,7 @@ private async Task RequestRoutineAsync(CancellationToken cancellationToken)
157
156
}
158
157
else
159
158
{
160
- requestStuckTime = 0f ;
159
+ requestStuckTime . Restart ( ) ;
161
160
requestProgress = _request . uploadProgress + _request . downloadProgress ;
162
161
}
163
162
You can’t perform that action at this time.
0 commit comments