fire-and-forget

Mixing async-await with fire-and-forget approach

我怕爱的太早我们不能终老 提交于 2020-03-05 04:11:51
问题 I'm writing a websocket server using .NET's HttpListener class. Essentially, I've got a HandleListener() function which wait for clients to connect and yield each client to HandleClient(WebSocket client) . So I currently have: private async void HandleListener() { try { while (listener != null && listener.IsListening) { HttpListenerContext listenerContext = await listener.GetContextAsync(); WebSocketContext webSocketContext = await listenerContext.AcceptWebSocketAsync(subProtocol: null);

Resolving Autofac components in background Tasks in ASP.NET

99封情书 提交于 2019-12-29 08:50:09
问题 Using Autofac in ASP.NET along with the ContainerDisposalModule, how can i support fire and forget calls that have component dependencies that need to be resolved? The problem I'm running into is that the ASP.NET request completes and disposes the lifetime scope of the request before the Task is ran, so any components that need to be resolved in the new thread fail with the message "Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already

PHP Fire and Forget POST Request

陌路散爱 提交于 2019-12-10 01:21:41
问题 I'm trying to create a fire and forget method in PHP so that I can POST data to a web server and not have wait for a response. I read that this could be achieved by using CURL like in the following code: $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_exec($ch); curl_close($ch); However I don't think it works as I expect. For example if the URL I send the request to has an error it causes my script to throw an error as well

PHP Fire and Forget POST Request

让人想犯罪 __ 提交于 2019-12-05 00:22:12
I'm trying to create a fire and forget method in PHP so that I can POST data to a web server and not have wait for a response. I read that this could be achieved by using CURL like in the following code: $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_exec($ch); curl_close($ch); However I don't think it works as I expect. For example if the URL I send the request to has an error it causes my script to throw an error as well. If it was fire and forget I would expect that not to happen. Can anyone tell me whether I'm doing

Simplest way to do a fire and forget method in c# 4.0

*爱你&永不变心* 提交于 2019-11-26 09:16:37
问题 I really like this question: Simplest way to do a fire and forget method in C#? I just want to know that now that we have Parallel extensions in C# 4.0 is there a better cleaner way to do Fire & Forget with Parallel linq? 回答1: Not an answer for 4.0, but worth noting that in .Net 4.5 you can make this even simpler with: #pragma warning disable 4014 Task.Run(() => { MyFireAndForgetMethod(); }).ConfigureAwait(false); #pragma warning restore 4014 The pragma is to disable the warning that tells

How can I fire and forget a process in Perl?

。_饼干妹妹 提交于 2019-11-26 09:03:41
问题 Can somebody please tell me how to fire-and-forget a process in Perl? I\'ve already looked at ruby: how to fire and forget a subprocess? for doing the same in Ruby. 回答1: From perlfaq8's answer to How do I start a process in the background? Several modules can start other processes that do not block your Perl program. You can use IPC::Open3, Parallel::Jobs, IPC::Run, and some of the POE modules. See CPAN for more details. You could also use system("cmd &") or you could use fork as documented