File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -47,10 +47,14 @@ and limitations under the License.
4747 修改标识:Senparc - 20181227
4848 修改描述:添加 GetDateTimeOffsetFromXml() 重写方法
4949
50+ 修改标识:Senparc - 20230326
51+ 修改描述:v2.0.5 添加 WaitingFor() 方法
52+
5053----------------------------------------------------------------*/
5154
5255
5356using System ;
57+ using System . Threading . Tasks ;
5458
5559namespace Senparc . CO2NET . Helpers
5660{
@@ -134,5 +138,29 @@ public static long GetUnixDateTime(DateTime dateTime)
134138 {
135139 return ( long ) ( dateTime . ToUniversalTime ( ) - BaseTime ) . TotalSeconds ;
136140 }
141+
142+ /// <summary>
143+ /// 自动等待
144+ /// </summary>
145+ /// <param name="waitingTime">总共等待时间</param>
146+ /// <param name="waitingInterval">每次等待间隔</param>
147+ /// <param name="work">每次等待之前执行的方法(可为空)</param>
148+ /// <returns></returns>
149+ public async Task WaitingFor ( TimeSpan waitingTime , TimeSpan waitingInterval , Action work = null )
150+ {
151+ while ( true )
152+ {
153+ var startTime = SystemTime . Now ;
154+ work ( ) ;
155+ var delayTime = Task . Delay ( waitingInterval ) ;
156+
157+ await delayTime ;
158+
159+ if ( SystemTime . NowDiff ( startTime ) >= waitingTime )
160+ {
161+ break ;
162+ }
163+ }
164+ }
137165 }
138166}
Original file line number Diff line number Diff line change 11<Project Sdk =" Microsoft.NET.Sdk" >
22 <PropertyGroup >
33 <TargetFrameworks >net451;netstandard2.0;netstandard2.1</TargetFrameworks >
4- <Version >2.0.4 </Version >
4+ <Version >2.0.5 </Version >
55 <LangVersion >8.0</LangVersion >
66 <AssemblyName >Senparc.CO2NET</AssemblyName >
77 <RootNamespace >Senparc.CO2NET</RootNamespace >
117117 v2.0.2 添加 XmlUtility.Deserialize() 重写方法
118118 v2.0.3 修改HttpClient请求超时的实现方式
119119 v2.0.4 XmlUtility 反序列化(Deserialize) 全面添加 rootNodeName 参数
120+ v2.0.5 添加 WaitingFor() 方法
120121 </PackageReleaseNotes >
121122 <RepositoryUrl >https://github.com/Senparc/Senparc.CO2NET</RepositoryUrl >
122123 <Configurations >Debug;Release;Test</Configurations >
You can’t perform that action at this time.
0 commit comments