Start Tasks and Retrieve Results

Learn to execute the task of sending emails and receiving confirmations in the form of notifications.

Simple examples

To keep our project and examples simple, we won’t send real emails. However, we still need some business logic for our experiments. We use the Process.sleep/1 function to pretend to send an email. This is usually a slow operation and can take a few seconds to complete. When called with an integer, Process.sleep/1 stops the current process for the given amount of time in milliseconds. This is very handy because we can simulate code that takes a long time to complete. We can also test various edge cases, as we’ll see later. Of course, in real-world production applications, we replace this with our actual business logic. But for now, let’s pretend we’re doing some very intensive work.

Sender example

We created the sender project in the previous lesson. Let’s open sender.ex and add the following:

Get hands-on with 1200+ tech skills courses.