本文整理汇总了C#中TimeUnit.ToMillis方法的典型用法代码示例。如果您正苦于以下问题:C# TimeUnit.ToMillis方法的具体用法?C# TimeUnit.ToMillis怎么用?C# TimeUnit.ToMillis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeUnit
的用法示例。
在下文中一共展示了TimeUnit.ToMillis方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecencyBoostScorerBuilder
public RecencyBoostScorerBuilder(string timeFacetName, float maxFactor, long from, long cutoff, TimeUnit timeunit)
{
_timeFacetName = timeFacetName;
_maxFactor = maxFactor;
_min = 1.0f;
_max = _maxFactor + _min;
_timeunit = timeunit;
_cutoffInMillis = _timeunit.ToMillis(cutoff);
_A = (_min - _max) / (((float)_cutoffInMillis) * ((float)_cutoffInMillis));
_now = timeunit.ToMillis(from);
}
示例2: Start
/// <summary>
/// Creates a new <see cref="ScheduledReporter"/> instance
/// </summary>
/// <param name="period">the amount of time between reports</param>
/// <param name="unit">the unit of <c>period</c></param>
public void Start(long period, TimeUnit unit)
{
this.threadTimer = new System.Timers.Timer { AutoReset = false, Interval = unit.ToMillis(period) };
this.threadTimer.Elapsed += delegate
{
try
{
report();
}
catch (Exception ex)
{
LOG.ErrorFormat("Exception was thrown from {0}. Exception was suppressed. Exception: {1}", typeof(ScheduledReporter), ex);
}
threadTimer.Start();
};
threadTimer.Start();
}
示例3: GetTimeInMillis
private long GetTimeInMillis(long time, TimeUnit timeunit)
{
return timeunit != null ? timeunit.ToMillis(time) : time;
}
示例4: SetTimeout
/// <summary>Sets the timeout.</summary>
/// <remarks>
/// Sets the timeout.
/// The timeout determines the maximum lifespan of a transaction. So if a transaction is configured with a
/// timeout of 2 minutes, then it will automatically rollback if it hasn't committed yet.
/// </remarks>
/// <param name="timeout">the timeout.</param>
/// <param name="timeUnit">the TimeUnit of the timeout.</param>
/// <returns>the updated TransactionOptions</returns>
/// <exception cref="System.ArgumentException">if timeout smaller or equal than 0, or timeUnit is null.</exception>
/// <seealso cref="GetTimeoutMillis()">GetTimeoutMillis()</seealso>
public TransactionOptions SetTimeout(long timeout, TimeUnit timeUnit)
{
if (timeout <= 0)
{
throw new ArgumentException("Timeout must be positive!");
}
_timeoutMillis = timeUnit.ToMillis(timeout);
return this;
}
示例5: Convert
public static long Convert(this TimeUnit timeUnit, long d, TimeUnit u)
{
switch (timeUnit)
{
case TimeUnit.NANOSECONDS:
return u.ToNanos(d);
case TimeUnit.MICROSECONDS:
return u.ToMicros(d);
case TimeUnit.MILLISECONDS:
return u.ToMillis(d);
case TimeUnit.SECONDS:
return u.ToSeconds(d);
case TimeUnit.MINUTES:
return u.ToMinutes(d);
case TimeUnit.HOURS:
return u.ToHours(d);
case TimeUnit.DAYS:
return u.ToDays(d);
}
return d;
}
示例6: GetTimeInMillis
private long GetTimeInMillis(long time, TimeUnit timeunit)
{
return timeunit.ToMillis(time);
}
示例7: TryAcquire
/// <exception cref="System.Exception"></exception>
public virtual bool TryAcquire(int permits, long timeout, TimeUnit unit)
{
CheckNegative(permits);
var request = SemaphoreTryAcquireCodec.EncodeRequest(name, permits, unit.ToMillis(timeout));
return Invoke(request, m => SemaphoreTryAcquireCodec.DecodeResponse(m).response);
}