@@ -157,8 +157,9 @@ private Task StartPollTask(CancellationToken ct)
157157 {
158158 if ( errorCode != ErrorCode . NoError )
159159 {
160- ( ( TaskCompletionSource < List < CreateTopicReport > > ) adminClientResult ) . TrySetException (
161- new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ;
160+ Task . Run ( ( ) =>
161+ ( ( TaskCompletionSource < List < CreateTopicReport > > ) adminClientResult ) . TrySetException (
162+ new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ) ;
162163 return ;
163164 }
164165
@@ -167,11 +168,14 @@ private Task StartPollTask(CancellationToken ct)
167168
168169 if ( result . Any ( r => r . Error . IsError ) )
169170 {
170- ( ( TaskCompletionSource < List < CreateTopicReport > > ) adminClientResult ) . TrySetException ( new CreateTopicsException ( result ) ) ;
171+ Task . Run ( ( ) =>
172+ ( ( TaskCompletionSource < List < CreateTopicReport > > ) adminClientResult ) . TrySetException (
173+ new CreateTopicsException ( result ) ) ) ;
171174 }
172175 else
173176 {
174- ( ( TaskCompletionSource < List < CreateTopicReport > > ) adminClientResult ) . TrySetResult ( result ) ;
177+ Task . Run ( ( ) =>
178+ ( ( TaskCompletionSource < List < CreateTopicReport > > ) adminClientResult ) . TrySetResult ( result ) ) ;
175179 }
176180 }
177181 break ;
@@ -180,8 +184,9 @@ private Task StartPollTask(CancellationToken ct)
180184 {
181185 if ( errorCode != ErrorCode . NoError )
182186 {
183- ( ( TaskCompletionSource < List < DeleteTopicReport > > ) adminClientResult ) . TrySetException (
184- new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ;
187+ Task . Run ( ( ) =>
188+ ( ( TaskCompletionSource < List < DeleteTopicReport > > ) adminClientResult ) . TrySetException (
189+ new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ) ;
185190 return ;
186191 }
187192
@@ -191,11 +196,14 @@ private Task StartPollTask(CancellationToken ct)
191196
192197 if ( result . Any ( r => r . Error . IsError ) )
193198 {
194- ( ( TaskCompletionSource < List < DeleteTopicReport > > ) adminClientResult ) . TrySetException ( new DeleteTopicsException ( result ) ) ;
199+ Task . Run ( ( ) =>
200+ ( ( TaskCompletionSource < List < DeleteTopicReport > > ) adminClientResult ) . TrySetException (
201+ new DeleteTopicsException ( result ) ) ) ;
195202 }
196203 else
197204 {
198- ( ( TaskCompletionSource < List < DeleteTopicReport > > ) adminClientResult ) . TrySetResult ( result ) ;
205+ Task . Run ( ( ) =>
206+ ( ( TaskCompletionSource < List < DeleteTopicReport > > ) adminClientResult ) . TrySetResult ( result ) ) ;
199207 }
200208 }
201209 break ;
@@ -204,8 +212,9 @@ private Task StartPollTask(CancellationToken ct)
204212 {
205213 if ( errorCode != ErrorCode . NoError )
206214 {
207- ( ( TaskCompletionSource < List < CreatePartitionsReport > > ) adminClientResult ) . TrySetException (
208- new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ;
215+ Task . Run ( ( ) =>
216+ ( ( TaskCompletionSource < List < CreatePartitionsReport > > ) adminClientResult ) . TrySetException (
217+ new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ) ;
209218 return ;
210219 }
211220
@@ -215,11 +224,14 @@ private Task StartPollTask(CancellationToken ct)
215224
216225 if ( result . Any ( r => r . Error . IsError ) )
217226 {
218- ( ( TaskCompletionSource < List < CreatePartitionsReport > > ) adminClientResult ) . TrySetException ( new CreatePartitionsException ( result ) ) ;
227+ Task . Run ( ( ) =>
228+ ( ( TaskCompletionSource < List < CreatePartitionsReport > > ) adminClientResult ) . TrySetException (
229+ new CreatePartitionsException ( result ) ) ) ;
219230 }
220231 else
221232 {
222- ( ( TaskCompletionSource < List < CreatePartitionsReport > > ) adminClientResult ) . TrySetResult ( result ) ;
233+ Task . Run ( ( ) =>
234+ ( ( TaskCompletionSource < List < CreatePartitionsReport > > ) adminClientResult ) . TrySetResult ( result ) ) ;
223235 }
224236 }
225237 break ;
@@ -228,8 +240,9 @@ private Task StartPollTask(CancellationToken ct)
228240 {
229241 if ( errorCode != ErrorCode . NoError )
230242 {
231- ( ( TaskCompletionSource < List < DescribeConfigsResult > > ) adminClientResult ) . TrySetException (
232- new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ;
243+ Task . Run ( ( ) =>
244+ ( ( TaskCompletionSource < List < DescribeConfigsResult > > ) adminClientResult ) . TrySetException (
245+ new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ) ;
233246 return ;
234247 }
235248
@@ -238,12 +251,15 @@ private Task StartPollTask(CancellationToken ct)
238251
239252 if ( result . Any ( r => r . Error . IsError ) )
240253 {
241- ( ( TaskCompletionSource < List < DescribeConfigsResult > > ) adminClientResult ) . TrySetException ( new DescribeConfigsException ( result ) ) ;
254+ Task . Run ( ( ) =>
255+ ( ( TaskCompletionSource < List < DescribeConfigsResult > > ) adminClientResult ) . TrySetException (
256+ new DescribeConfigsException ( result ) ) ) ;
242257 }
243258 else
244259 {
245260 var nr = result . Select ( a => new DescribeConfigsResult { ConfigResource = a . ConfigResource , Entries = a . Entries } ) . ToList ( ) ;
246- ( ( TaskCompletionSource < List < DescribeConfigsResult > > ) adminClientResult ) . TrySetResult ( nr ) ;
261+ Task . Run ( ( ) =>
262+ ( ( TaskCompletionSource < List < DescribeConfigsResult > > ) adminClientResult ) . TrySetResult ( nr ) ) ;
247263 }
248264 }
249265 break ;
@@ -252,8 +268,9 @@ private Task StartPollTask(CancellationToken ct)
252268 {
253269 if ( errorCode != ErrorCode . NoError )
254270 {
255- ( ( TaskCompletionSource < List < AlterConfigsReport > > ) adminClientResult ) . TrySetException (
256- new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ;
271+ Task . Run ( ( ) =>
272+ ( ( TaskCompletionSource < List < AlterConfigsReport > > ) adminClientResult ) . TrySetException (
273+ new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ) ;
257274 return ;
258275 }
259276
@@ -263,11 +280,14 @@ private Task StartPollTask(CancellationToken ct)
263280
264281 if ( result . Any ( r => r . Error . IsError ) )
265282 {
266- ( ( TaskCompletionSource < List < AlterConfigsReport > > ) adminClientResult ) . TrySetException ( new AlterConfigsException ( result ) ) ;
283+ Task . Run ( ( ) =>
284+ ( ( TaskCompletionSource < List < AlterConfigsReport > > ) adminClientResult ) . TrySetException (
285+ new AlterConfigsException ( result ) ) ) ;
267286 }
268287 else
269288 {
270- ( ( TaskCompletionSource < List < AlterConfigsReport > > ) adminClientResult ) . TrySetResult ( result ) ;
289+ Task . Run ( ( ) =>
290+ ( ( TaskCompletionSource < List < AlterConfigsReport > > ) adminClientResult ) . TrySetResult ( result ) ) ;
271291 }
272292 }
273293 break ;
0 commit comments