# Microsoft.Threading.Tasks.Extensions.Desktop

**Kind:** Service

**Source:** `Pams/Logic/Pams.Email/Pams.Email.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`Microsoft.Threading.Tasks.Extensions.Desktop` is a NuGet package dependency declared by `Pams.Email.csproj`. It provides task-based asynchronous APIs required by the Pams.Email project when running on desktop .NET targets.

## Diagram

```mermaid
sequenceDiagram
    participant App as Calling Application
    participant Email as Pams.Email
    participant Tasks as Microsoft.Threading.Tasks.Extensions.Desktop

    App->>Email: Send email request
    Email->>Tasks: Await asynchronous operation
    Tasks-->>Email: Task completion result
    Email-->>App: Email operation result
```

## Usage

```ts
async function sendEmail(message: {
  to: string;
  subject: string;
  body: string;
}) {
  const response = await fetch("/api/email/send", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(message),
  });

  if (!response.ok) {
    throw new Error("Email request failed");
  }

  return response.json();
}

await sendEmail({
  to: "user@example.com",
  subject: "Status update",
  body: "The requested email was sent.",
});
```

## AI Coding Instructions

- Keep the package reference in `Pams.Email.csproj` aligned with the desktop .NET target used by the project.
- Use `async` and `await` when calling email operations that return tasks.
- Do not add this package to browser or TypeScript projects; it is consumed by the .NET email service.
- Check package compatibility before changing the project target framework or package version.
