Questions tagged [fire-and-forget]

Fire-and-Forget interaction pattern

A participant has identified a conversation partner and wants to pass information. The originator sends a Fire-and-Forget message and does not expect any response from the recipient. It is the simplest of all conversations.

This case is also called a "fire and forget": When you start an asynchronous task chain, but you don't care about when it's finished. You want to execute some offloaded work and you don't need to get result back. When the function returns, all you know is that everything up to the first await has executed.

// C#
async void SomethingAsync() { ... }

// Java
new Runnable() {
    @Override
    public void run() { ... }
};
92 questions
131
votes
4 answers

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

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?
Jonathon Kresner
  • 2,793
  • 5
  • 29
  • 40
20
votes
2 answers

PHP Fire and Forget POST Request

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,…
diggersworld
  • 12,770
  • 24
  • 84
  • 119
15
votes
2 answers

Best practices to Fire and Forget an async method to send non essential metric

Waiting for a non-essential metrics to be sent makes no sense to me, as it adds latency (waiting for the server's response) on each call to the back-end dotnet core service, which might happen multiple times per client call. Still, logging an error…
David Gourde
  • 3,709
  • 2
  • 31
  • 65
14
votes
4 answers

Considerations for not awaiting a Task in an asynchronous method

I'm working on a Web API project which uses Azure's managed cache service to cache database results in memory to improve response times and alleviate duplicate traffic to the database. When attempting to put a new item in the cache, occasionally a…
Jesse Carter
  • 20,062
  • 7
  • 64
  • 101
14
votes
4 answers

How can I fire and forget a process in Perl?

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.
Alex Marshall
  • 10,162
  • 15
  • 72
  • 117
11
votes
4 answers

Fire and forget, using Task.Run or just calling an async method without await

In general especially when it comes to libraries or console apps, in order to fire and forget an async method, is it better to just call the async method without awaiting it or use Task.Run? Basically: public static void Main() { // Doing _…
NavidM
  • 1,515
  • 1
  • 16
  • 27
9
votes
2 answers

Fire and Forget Sql Server Stored Procedure from C#

I'm doing a queued jobs and at the end of each job I want to fire an SP which will do a lot of processing on data. So I don't want to wait for completion of the SP and I just want to move to next job immediately after triggering the SP. Stored…
IsmailS
  • 10,797
  • 21
  • 82
  • 134
8
votes
4 answers

Fire and forget goroutine golang

I have written an API that makes DB calls and does some business logic. I am invoking a goroutine that must perform some operation in the background. Since the API call should not wait for this background task to finish, I am returning 200 OK…
Anish
  • 121
  • 1
  • 8
8
votes
2 answers

Resolving Autofac components in background Tasks in ASP.NET

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…
user1591480
  • 83
  • 2
  • 3
7
votes
3 answers

fire and forget an async Task method sometimes not invoke

I have an async method: public async Task DoSomethingAsync(){ ... await ... await ... .... return await SaveAsync(); } In most time, I call this method by: await DoSomethingAsync() This call works as expected. But somewhere, I…
langtu
  • 1,198
  • 1
  • 10
  • 23
7
votes
2 answers

Fire and forget with java.util.concurrent

How to go about implementing a "fire and forget" behavior with java.util.concurrency? I tried: ExecutorService executor = Executors.newSingleThreadExecutor(); public void push(Callable task) { Future future =…
Philippe Blayo
  • 10,610
  • 14
  • 48
  • 65
6
votes
2 answers

WCF client causes server to hang until connection fault

The below text is an effort to expand and add color to this question: How do I prevent a misbehaving client from taking down the entire service? I have essentially this scenario: a WCF service is up and running with a client callback having a…
6
votes
1 answer

Asyncio "fire and forget" tasks in a separate thread

I have a long-running synchronous Python program, where I'd like to run ~10 "fire and forget" tasks every second. These tasks hit a remote API and do not need to return any value. I tried this answer, but it requires too much CPU/memory to spawn and…
pir
  • 5,513
  • 12
  • 63
  • 101
5
votes
1 answer

Do scala futures continue running after response in akka-http?

I have a REST service written in akka-http which exposes a /fire endpoint. When that endpoint is called my service should send a file, usually of ~50MB to a different service. But the /fire endpoint should return immediately to the caller and keep…
Fr.Usai
  • 384
  • 2
  • 17
4
votes
4 answers

Fire, Forget, and Return Value in Python3.7

I have the following scenario: I have a python server that upon receiving a request, needs to parse some information, return the result to the user as quickly as possible, and then clean up after itself. I tried to design it using the following…
1
2 3 4 5 6 7