Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SendAsync< TInput >() [2/2]

static Task< bool > System.Threading.Tasks.Dataflow.DataflowBlock.SendAsync< TInput > ( this ITargetBlock< TInput > target,
TInput item,
CancellationToken cancellationToken )
inlinestatic

Definition at line 1285 of file DataflowBlock.cs.

1286 {
1287 if (target == null)
1288 {
1289 throw new ArgumentNullException("target");
1290 }
1291 if (cancellationToken.IsCancellationRequested)
1292 {
1293 return Common.CreateTaskFromCancellation<bool>(cancellationToken);
1294 }
1296 try
1297 {
1298 switch (target.OfferMessage(Common.SingleMessageHeader, item, null, consumeToAccept: false))
1299 {
1300 case DataflowMessageStatus.Accepted:
1302 case DataflowMessageStatus.DecliningPermanently:
1304 default:
1306 break;
1307 }
1308 }
1309 catch (Exception ex)
1310 {
1311 Common.StoreDataflowMessageValueIntoExceptionData(ex, item);
1312 return Common.CreateTaskFromException<bool>(ex);
1313 }
1314 sendAsyncSource.OfferToTarget();
1315 return sendAsyncSource.Task;
1316 }
static readonly Task< bool > CompletedTaskWithFalseResult
Definition Common.cs:30
static readonly Task< bool > CompletedTaskWithTrueResult
Definition Common.cs:28
static readonly DataflowMessageHeader SingleMessageHeader
Definition Common.cs:26

References System.cancellationToken, System.Threading.Tasks.Dataflow.Internal.Common.CompletedTaskWithFalseResult, System.Threading.Tasks.Dataflow.Internal.Common.CompletedTaskWithTrueResult, System.item, and System.Threading.Tasks.Dataflow.Internal.Common.SingleMessageHeader.