Here are the examples of the csharp api System.Threading.Tasks.Task.FromResult(long) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
106 Examples
19
Source : FakeConnectionMultiplexer.cs
with MIT License
from AliBazzi
with MIT License
from AliBazzi
public Task<long> PublishReconfigureAsync(CommandFlags flags = CommandFlags.None) => Task.FromResult(-1L);
19
Source : QueryableExtensions.cs
with MIT License
from ansel86castro
with MIT License
from ansel86castro
public static Task<long> LongCountAsync<T>(this IQueryable<T> query)
{
if (IAsyncQueryExecutioner.Executioner == null)
return Task.FromResult(query.LongCount());
return IAsyncQueryExecutioner.Executioner.LongCountAsync(query);
}
19
Source : LocalCache.cs
with MIT License
from ansel86castro
with MIT License
from ansel86castro
public Task<long> Increment(string key, long value = 1, TimeSpan? expire= null)
{
bool taken = false;
try
{
spinLock.Enter(ref taken);
if (!_cache.TryGetValue(key, out object result))
{
result = 0L;
var entry = _cache.CreateEntry(key);
entry.SetValue(result);
if (expire != null)
entry.SetAbsoluteExpiration(expire.Value);
entry.Dispose();
}
var n = (long)result;
n += value;
_cache.Set(key, n);
return Task.FromResult<long>(n);
}
finally
{
if (taken)
{
spinLock.Exit();
}
}
}
19
Source : LocalCache.cs
with MIT License
from ansel86castro
with MIT License
from ansel86castro
public Task<long?> GetInteger(string key)
{
if (_cache.TryGetValue(key, out var l))
{
return Task.FromResult((long?)Convert.ToInt64(l));
}
return Task.FromResult((long?)null);
}
19
Source : QueryableExtensions.cs
with MIT License
from ansel86castro
with MIT License
from ansel86castro
public static Task<long> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken cancellationToken = default)
{
if (IAsyncQueryExecutioner.Executioner == null)
return Task.FromResult(source.Sum(selector));
return IAsyncQueryExecutioner.Executioner.SumAsync(source, selector);
}
19
Source : QueryableExtensions.cs
with MIT License
from ansel86castro
with MIT License
from ansel86castro
public static Task<long?> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long?>> selector, CancellationToken cancellationToken = default)
{
if (IAsyncQueryExecutioner.Executioner == null)
return Task.FromResult(source.Sum(selector));
return IAsyncQueryExecutioner.Executioner.SumAsync(source, selector);
}
19
Source : QueryableExtensions.cs
with MIT License
from ansel86castro
with MIT License
from ansel86castro
public static Task<long> LongCountAsync<T>(this IQueryable<T> query, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default)
{
if (IAsyncQueryExecutioner.Executioner == null)
return Task.FromResult(query.LongCount(predicate));
return IAsyncQueryExecutioner.Executioner.LongCountAsync(query, predicate);
}
19
Source : InMemoryProvider.cs
with Apache License 2.0
from asynkron
with Apache License 2.0
from asynkron
public Task<long> GetEventsAsync(string actorName, long indexStart, long indexEnd, Action<object> callback)
{
if (Events.TryGetValue(actorName, out var events))
{
foreach (var e in events.Where(e => e.Key >= indexStart && e.Key <= indexEnd))
{
callback(e.Value);
}
}
return Task.FromResult(0L);
}
19
Source : InMemoryProvider.cs
with Apache License 2.0
from asynkron
with Apache License 2.0
from asynkron
public Task DeleteSnapshotsAsync(string actorName, long inclusiveToIndex) => Task.FromResult(0L);
19
Source : InMemoryProvider.cs
with Apache License 2.0
from asynkron
with Apache License 2.0
from asynkron
Task<long> IEventStore.PersistEventAsync(string actorName, long index, object @event) => Task.FromResult(0L);
19
Source : Persistence.cs
with Apache License 2.0
from asynkron
with Apache License 2.0
from asynkron
public Task<long>
GetEventsAsync(string actorName, long indexStart, long indexEnd, Action<object> callback) =>
Task.FromResult(-1L);
19
Source : Persistence.cs
with Apache License 2.0
from asynkron
with Apache License 2.0
from asynkron
public Task<long> PersistEventAsync(string actorName, long index, object @event) => Task.FromResult(0L);
19
Source : InMemoryProvider.cs
with Apache License 2.0
from asynkron
with Apache License 2.0
from asynkron
public Task<long> GetEventsAsync(string actorName, long indexStart, long indexEnd, Action<object> callback)
{
var lastIndex = 0L;
if (_events.TryGetValue(actorName, out var events))
{
foreach (var e in events.Where(e => e.Key >= indexStart && e.Key <= indexEnd))
{
lastIndex = e.Key;
callback(e.Value);
}
}
return Task.FromResult(lastIndex);
}
19
Source : InMemoryProvider.cs
with Apache License 2.0
from asynkron
with Apache License 2.0
from asynkron
public Task<long> PersistEventAsync(string actorName, long index, object @event)
{
var events = _events.GetOrAdd(actorName, new Dictionary<long, object>());
events.Add(index, @event);
long max = events.Max(x => x.Key);
return Task.FromResult(max);
}
19
Source : MockReliableQueue.cs
with MIT License
from Azure-Samples
with MIT License
from Azure-Samples
public Task<long> GetCountAsync(ITransaction tx)
{
return Task.FromResult<long>(this.queue.Count);
}
19
Source : BalanceHistoryRepository.cs
with MIT License
from baking-bad
with MIT License
from baking-bad
public Task<long> Get(string address, DateTime timestamp)
{
var level = Time.FindLevel(timestamp, SearchMode.ExactOrLower);
if (level == -1) return Task.FromResult(0L);
return Get(address, level);
}
19
Source : AsyncQueryableExecuter.cs
with MIT License
from bing-framework
with MIT License
from bing-framework
public Task<long> LongCountAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default)
{
var provider = FindProvider(queryable);
return provider != null
? provider.LongCountAsync(queryable, cancellationToken)
: Task.FromResult(queryable.LongCount());
}
19
Source : AsyncQueryableExecuter.cs
with MIT License
from bing-framework
with MIT License
from bing-framework
public Task<long> LongCountAsync<T>(IQueryable<T> queryable, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default)
{
var provider = FindProvider(queryable);
return provider != null
? provider.LongCountAsync(queryable, predicate, cancellationToken)
: Task.FromResult(queryable.LongCount(predicate));
}
19
Source : AsyncQueryableExecuter.cs
with MIT License
from bing-framework
with MIT License
from bing-framework
public Task<long> SumAsync(IQueryable<long> source, CancellationToken cancellationToken = default)
{
var provider = FindProvider(source);
return provider != null
? provider.SumAsync(source, cancellationToken)
: Task.FromResult(source.Sum());
}
19
Source : AsyncQueryableExecuter.cs
with MIT License
from bing-framework
with MIT License
from bing-framework
public Task<long?> SumAsync(IQueryable<long?> source, CancellationToken cancellationToken = default)
{
var provider = FindProvider(source);
return provider != null
? provider.SumAsync(source, cancellationToken)
: Task.FromResult(source.Sum());
}
19
Source : AsyncQueryableExecuter.cs
with MIT License
from bing-framework
with MIT License
from bing-framework
public Task<long> SumAsync<T>(IQueryable<T> queryable, Expression<Func<T, long>> selector, CancellationToken cancellationToken = default)
{
var provider = FindProvider(queryable);
return provider != null
? provider.SumAsync(queryable, selector, cancellationToken)
: Task.FromResult(queryable.Sum(selector));
}
19
Source : AsyncQueryableExecuter.cs
with MIT License
from bing-framework
with MIT License
from bing-framework
public Task<long?> SumAsync<T>(IQueryable<T> queryable, Expression<Func<T, long?>> selector, CancellationToken cancellationToken = default)
{
var provider = FindProvider(queryable);
return provider != null
? provider.SumAsync(queryable, selector, cancellationToken)
: Task.FromResult(queryable.Sum(selector));
}
19
Source : LocalTimeProvider.cs
with Apache License 2.0
from bosima
with Apache License 2.0
from bosima
public async Task<long> GetCurrentUtcMillisecondsAsync()
{
return await Task.FromResult(GetCurrentUtcMilliseconds());
}
19
Source : BasicRepositoryBase.cs
with GNU Lesser General Public License v3.0
from cnAbp
with GNU Lesser General Public License v3.0
from cnAbp
public virtual Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return Task.FromResult(GetCount());
}
19
Source : ZookeeperBootstrapper.cs
with Apache License 2.0
from Coldairarrow
with Apache License 2.0
from Coldairarrow
private async Task<long> GetWorkerIdAsync()
{
if (_zookeeperClient == null)
await BuildZookeeperClient();
//项目根节点
await CheckNodeExists($"/{_projectKey}");
//WorkerId记录根节点
await CheckNodeExists(_workerIdRecordRootPath);
//WorkerId临时根节点
await CheckNodeExists(_workderIdTmpRootPath);
//同步节点
await SyncNodes();
//分配WorkerId
for (int i = 1; i < 1024; i++)
{
string recordNodePath = $"{_workerIdRecordRootPath}/{i}";
string tmpNodePath = $"{_workderIdTmpRootPath}/{i}";
if (await _zookeeperClient.existsAsync(recordNodePath, true) == null &&
await _zookeeperClient.existsAsync(tmpNodePath, true) == null
)
{
await _zookeeperClient.createAsync(tmpNodePath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
WorkerIdRecord newData = new WorkerIdRecord
{
StartTime = DateTime.Now
};
await _zookeeperClient.createAsync(recordNodePath, Encoding.UTF8.GetBytes(newData.ToJson()), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
return await Task.FromResult((long)i);
}
}
throw new Exception("WorkerId已用完!");
}
19
Source : ListControllerTests.cs
with MIT License
from ContactAssistApp
with MIT License
from ContactAssistApp
[TestMethod]
public async Task HeadAsync_ContentLengthHeaderSetWithValidParams()
{
// Arrange
long repoResponse = 1024;
this._repo
.Setup(
r => r.GetLatestRegionSizeAsync(
It.IsAny<Enreplacedies.Geospatial.Region>(),
It.IsAny<long>(),
CancellationToken.None
)
)
.Returns(Task.FromResult(repoResponse));
// Act
ActionResult controllerResponse = await this._controller
.HeadAsync(
10.1234,
-10.1234,
4,
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
CancellationToken.None
);
// replacedert
replacedert.IsNotNull(controllerResponse);
replacedert.IsNotNull(this._controller.HttpContext.Response.ContentLength);
replacedert.AreEqual(repoResponse, this._controller.HttpContext.Response.ContentLength);
}
19
Source : ListControllerTests.cs
with MIT License
from ContactAssistApp
with MIT License
from ContactAssistApp
[TestMethod]
public async Task HeadAsync_ContentLengthHeaderSetWithValidParams()
{
// Arrange
long repoResponse = 1024;
this._repo
.Setup(
r => r.GetLatestRegionSizeAsync(
It.IsAny<Enreplacedies.Geospatial.Region>(),
It.IsAny<long>(),
CancellationToken.None
)
)
.Returns(Task.FromResult(repoResponse));
// Act
ActionResult controllerResponse = await this._controller
.HeadAsync(
10,
-10,
4,
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
CancellationToken.None
);
// replacedert
replacedert.IsNotNull(controllerResponse);
replacedert.IsNotNull(this._controller.HttpContext.Response.ContentLength);
replacedert.AreEqual(repoResponse, this._controller.HttpContext.Response.ContentLength);
}
19
Source : InfectionReportServiceTests.cs
with MIT License
from ContactAssistApp
with MIT License
from ContactAssistApp
[TestMethod]
public async Task GetLatestRegionDataSizeAsync_ReturnsSize()
{
// Arrange
Region region = new Region(10, -10, 4);
long expectedResult = 1024;
this._repo
.Setup(r => r.GetLatestRegionSizeAsync(It.IsAny<Region>(), It.IsAny<long>(), CancellationToken.None))
.Returns(Task.FromResult(expectedResult));
// Act
long result = await this._service.GetLatestRegionDataSizeAsync(
region,
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
CancellationToken.None
);
// replacedert
replacedert.AreEqual(expectedResult, result);
}
19
Source : AsyncQueryableExtensions.cs
with MIT License
from Danielku15
with MIT License
from Danielku15
public static Task<long> LongCountAsync<T>(this IQueryable<T> queryable, CancellationToken cancellationToken)
{
return Task.FromResult(queryable.LongCount());
}
19
Source : DiscordGatewayLatencyEndpoint.cs
with MIT License
from discord-csharp
with MIT License
from discord-csharp
public Task<long?> GetLatencyAsync(
CancellationToken cancellationToken)
=> Task.FromResult<long?>(Convert.ToInt64(_discordClient.Latency));
19
Source : RedisSlidingWIndowRateLimiterTests.cs
with Apache License 2.0
from DomainGroupOSS
with Apache License 2.0
from DomainGroupOSS
private static (RedisRateLimiter RedisRateLimiter,
Mock<IConnectionMultiplexer> ConnectionMultiplexerMock,
Mock<IDatabase> DatabaseMock,
Mock<ITransaction> TransactionMock,
Mock<ITransaction> PostViolationTransactionMock,
Mock<IClock> clockMock)
Arrange(string requestId, string method, string routeTemplate,
AllowedConsumptionRate allowedCallRate,
DateTime utcDateTime, long numberOfRequestsMadeSoFar)
{
var clockMock = GetClockMock(utcDateTime);
var cacheKey = new RateLimitCacheKey(requestId, method, "localhost", routeTemplate,
allowedCallRate,
_ => allowedCallRate.Unit.ToString(), clockMock.Object);
var connectionMultiplexerMock = new Mock<IConnectionMultiplexer>(MockBehavior.Strict);
var dbMock = new Mock<IDatabase>(MockBehavior.Strict);
var transactionMock = new Mock<ITransaction>(MockBehavior.Strict);
transactionMock.Setup(redisTransaction =>
redisTransaction.SortedSetRemoveRangeByScoreAsync(
cacheKey.ToString(), 0,
utcDateTime.Ticks - (long)cacheKey.Unit, It.IsAny<Exclude>(),
It.IsAny<CommandFlags>())).Returns(Task.FromResult(10L));
transactionMock.Setup(redisTransaction =>
redisTransaction.SortedSetAddAsync(
cacheKey.ToString(), It.IsAny<RedisValue>(), utcDateTime.Ticks, It.IsAny<When>(),
It.IsAny<CommandFlags>())).Returns(Task.FromResult(true));
transactionMock.Setup(redisTransaction =>
redisTransaction.SortedSetLengthAsync(
cacheKey.ToString(), It.IsAny<double>(), It.IsAny<double>(), It.IsAny<Exclude>(),
It.IsAny<CommandFlags>())).Returns(
Task.FromResult(numberOfRequestsMadeSoFar));
transactionMock.Setup(redisTransaction =>
redisTransaction.KeyExpireAsync(
cacheKey.ToString(), cacheKey.Expiration.Add(new TimeSpan(0, 1, 0)), It.IsAny<CommandFlags>())).Returns(Task.FromResult(true));
transactionMock.Setup(redisTransaction =>
redisTransaction.ExecuteAsync(CommandFlags.None)).Returns(Task.FromResult(true));
var postViolationTransactionMock = new Mock<ITransaction>(MockBehavior.Strict);
postViolationTransactionMock.Setup(redisTransaction =>
redisTransaction.SortedSetRangeByRankWithScoresAsync(
cacheKey.ToString(), 0, 0, It.IsAny<Order>(),
It.IsAny<CommandFlags>()))
.Returns(Task.FromResult(new SortedSetEntry[] { new SortedSetEntry(It.IsAny<RedisValue>(), utcDateTime.Ticks)}));
postViolationTransactionMock.Setup(redisTransaction =>
redisTransaction.ExecuteAsync(CommandFlags.None)).Returns(Task.FromResult(true));
dbMock.SetupSequence(db => db.CreateTransaction(null))
.Returns(transactionMock.Object)
.Returns(postViolationTransactionMock.Object);
connectionMultiplexerMock.Setup(connection => connection.IsConnected).Returns(true);
connectionMultiplexerMock.Setup(connection => connection.GetDatabase(-1, null)).Returns(dbMock.Object);
var rateLimiter = new SlidingTimeWindowRateLimiter("http://localhost",
clock: clockMock.Object,
connectToRedisFunc: async () => await Task.FromResult(connectionMultiplexerMock.Object),
countThrottledRequests: true);
return (rateLimiter, connectionMultiplexerMock, dbMock,
transactionMock, postViolationTransactionMock, clockMock);
}
19
Source : MockReliableQueue.cs
with MIT License
from dotnet
with MIT License
from dotnet
public Task<long> GetCountAsync(ITransaction tx)
{
return Task.FromResult<long>(queue.Count);
}
19
Source : NoneETLTaskRepository.cs
with Apache License 2.0
from dotnetcore
with Apache License 2.0
from dotnetcore
public Task<long> Startup(string configPath, string code)
{
return Task.FromResult<long>(-1);
}
19
Source : WorldGrain.cs
with MIT License
from dotnetGame
with MIT License
from dotnetGame
public Task<long> GetAge() => Task.FromResult(State.WorldAge);
19
Source : ProducerActor.cs
with Apache License 2.0
from eaba
with Apache License 2.0
from eaba
protected internal override async ValueTask<long> LastSequenceId()
{
return await Task.FromResult(_lastSequenceIdPublished);
}
19
Source : FileJournal.cs
with Apache License 2.0
from EdwinVW
with Apache License 2.0
from EdwinVW
public override Task<long> ReadHighestSequenceNrAsync(string persistenceId, long fromSequenceNr)
{
LoadMessages(persistenceId);
return Task.FromResult(HighestSequenceNr(persistenceId));
}
19
Source : DebugRepositoryWarehouse.cs
with MIT License
from eznew-net
with MIT License
from eznew-net
public async Task<long> CountAsync(IQuery query)
{
long allCount = 0;
var countResult = WarehouseManager.Count<TEnreplacedy>(query);
allCount += countResult.Count;
return await Task.FromResult(allCount).ConfigureAwait(false);
}
19
Source : MockReliableDictionary.cs
with MIT License
from FabricatorsGuild
with MIT License
from FabricatorsGuild
public Task<long> GetCountAsync()
{
return Task.FromResult((long)this._dictionary.Count);
}
19
Source : MockReliableDictionary.cs
with MIT License
from FabricatorsGuild
with MIT License
from FabricatorsGuild
public Task<long> GetCountAsync(ITransaction tx)
{
return Task.FromResult((long)this._dictionary.Count);
}
19
Source : MockReliableQueue.cs
with MIT License
from FabricatorsGuild
with MIT License
from FabricatorsGuild
public Task<long> GetCountAsync()
{
return Task.FromResult((long)this._queue.Count);
}
19
Source : MockReliableQueue.cs
with MIT License
from FabricatorsGuild
with MIT License
from FabricatorsGuild
public Task<long> GetCountAsync(ITransaction tx)
{
return Task.FromResult<long>(this._queue.Count);
}
19
Source : MockTransaction.cs
with MIT License
from FabricatorsGuild
with MIT License
from FabricatorsGuild
public Task<long> GetVisibilitySequenceNumberAsync()
{
return Task.FromResult(0L);
}
19
Source : CalculatorService.cs
with MIT License
from Haishi2016
with MIT License
from Haishi2016
public Task<long> Add(int a, int b)
{
return Task.FromResult<long>(a + b);
}
19
Source : CalculatorService.cs
with MIT License
from Haishi2016
with MIT License
from Haishi2016
public Task<long> Subtract(int a, int b)
{
return Task.FromResult<long>(a - b);
}
19
Source : Program.cs
with MIT License
from horsdal
with MIT License
from horsdal
Task<long> GetStartIdFromDatastore() => Task.FromResult(0L);
19
Source : EventsourcedProcessor.cs
with Apache License 2.0
from Horusiath
with Apache License 2.0
from Horusiath
public sealed override Task<long> Write()
{
//WARNING: don't change that into async await - if you do, `this.processedEvents`
//may end up being accessed concurrently from `this.OnEvent` running on another thread
if (LastSequenceNr > processingProgress)
{
var task = WriteBatches(processedEvents, processingProgress, LastSequenceNr);
this.processedEvents = ImmutableArray<IReadOnlyCollection<DurableEvent>>.Empty;
return task;
}
else return Task.FromResult(processingProgress);
}
19
Source : SqlConnectionGremlin.cs
with MIT License
from houseofcat
with MIT License
from houseofcat
public Task<long> GetOpenConnectionsCountAsync()
{
var openCount = 0L;
foreach (var kvp in Connections)
{
if (kvp.Value.State == ConnectionState.Open)
{ openCount++; }
}
return Task.FromResult(openCount);
}
19
Source : MockReliableDictionary.cs
with MIT License
from jessebenson
with MIT License
from jessebenson
public Task<long> GetCountAsync(ITransaction tx)
{
return Task.FromResult((long) _state.Count);
}
19
Source : ProxyGeneratorAsyncCallsTest.cs
with Apache License 2.0
from JetBrains
with Apache License 2.0
from JetBrains
public Task<long> lSum(long a, long b) => Task.FromResult(a + b);
19
Source : AsyncQueryableExecuter.cs
with MIT License
from linfx
with MIT License
from linfx
public Task<long> SumAsync(IQueryable<long> queryable, CancellationToken cancellationToken = default)
{
var provider = FindProvider(queryable);
return provider != null
? provider.SumAsync(queryable, cancellationToken)
: Task.FromResult(queryable.Sum());
}
See More Examples