context.CompleteTask usage

24 مرّة مشاهدة
التخطي إلى أول رسالة غير مقروءة

Oren Kupershtein

غير مقروءة،
28‏/05‏/2018، 10:32:07 ص28‏/5‏/2018
إلى masstransit-discuss
Hi,
when implementing a consumer, do i need to await context.CompleteTask?
what can be the impact  of not calling it?

for example:
  public async Task Consume(ConsumeContext<MyEvent> context)
        {
            //do some logic here
            await context.CompleteTask;
        }

Chris Patterson

غير مقروءة،
28‏/05‏/2018، 6:05:38 م28‏/5‏/2018
إلى masstrans...@googlegroups.com
No, you do not. Just write your Consume method like any other async method. There isn't any magic involved.

If you're writing a non-async Consume method, you can return Task.CompletedTask (.NET Core or 4.6.something only). If you're on .NET 4.5.2 use MassTransit.Util.TaskUtil.Completed;

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/8ab02ef1-07ab-415b-b076-c6c4b5c1b877%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

الرد على الكل
رد على الكاتب
إعادة توجيه
0 رسالة جديدة