Jroland / kafka-net

Native C# client for Kafka queue servers.
Apache License 2.0
482 stars 232 forks source link

Release Consume thread when Consumer disposed #97

Open ksavelev opened 8 years ago

ksavelev commented 8 years ago

Running code below;

var consumer = new Consumer(...); // initialize consumer
Task.Factory.StartNew(() =>
{
    Console.WriteLine("Consumer started");
    foreach (var m in bc.Consume()) Console.WriteLine(Encoding.UTF8.GetString(m.Value));
    Console.WriteLine("Consumer finished");
});
// wait a sec;
consumer.Dispose();

will never print Consumer finished even though consumer is in unusable state and bc.Consume() will never yield any result anymore.

Is it possible to change behavior of Consumer on Dispose so it will release the thread that runs the .Consume() method?