Integrate Mellowtel into your Windows desktop application to allow users to share their unused internet bandwidth in exchange for rewards or premium features.Documentation Index
Fetch the complete documentation index at: https://docs.mellowtel.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- A Mellowtel account and Integration ID from the dashboard. Each desktop app gets its own unique Integration ID.
- .NET 10 SDK
- Windows 10 or Windows 11
- A .NET desktop application (Console, WPF, or Windows Forms)
Want to see a complete, real-world integration before wiring this into your own app? The mellowtel-pomodoro-windows WPF sample shows the full flow end-to-end: consent dialog, settings toggle, and background lifecycle.
Installation
Mellowtel for Windows ships on NuGet asMellowtel.Win.
1. Install the Package
From your project directory:PackageReference to your .csproj:
2. Add to Your Code
Replace
YOUR_INTEGRATION_ID with the Integration ID from your Mellowtel dashboard, and set PluginId to a stable identifier for your app. ShowConsentDialog() is your own UI that returns true only when the user explicitly agrees. See User Consent below.Configuration options
MellowtelOptions lets you tune a few things:
| Property | Type | Default | Description |
|---|---|---|---|
PluginId | string | "mellowtel-win" | Stable identifier for your app. Set this to something unique. |
MaxDailyRate | int | Built-in default | Max requests the SDK will handle per day. |
DisableLogs | bool | true | Set to false to enable SDK logs during development. |
Examples by Application Type
- Console App
- WPF App
- Windows Forms
Observing connection state
TheMellowtel instance exposes a ConnectionStateChanged event that fires whenever the underlying WebSocket to Mellowtel’s backend connects or disconnects. The WPF and Windows Forms examples above subscribe to it to drive a status indicator. The payload is a bool where true means connected and false means disconnected.
The event fires on a background thread, so UI frameworks that enforce thread affinity must marshal updates onto the UI thread. In WPF use Dispatcher.Invoke, and in Windows Forms use Control.Invoke (both shown in the examples above).
About the WPF
async void OnClosing pattern. The WPF example above uses protected override async void OnClosing, which is the simplest form but has a subtle issue: base.OnClosing(e) is called synchronously while StopAsync() is still awaiting, so the window can close before cleanup finishes. For most apps this is fine because the process exits immediately afterwards. If you need a guaranteed graceful shutdown (for example, to flush telemetry), follow the Microsoft-documented deferral pattern where you set e.Cancel = true, await your async work, and then close the window explicitly.User Consent
What your consent dialog must include
Explain what Mellowtel does
Use plain language. Example: “This app uses Mellowtel to share your unused internet bandwidth. This allows you to [benefit/feature]. You can opt out at any time in settings.”
Link to policies
Include links to the Terms of Service and Privacy Policy.
Let users change their consent in settings
GetOptInDetails() returns the opt-in status alongside the opt-in and opt-out timestamps:
Troubleshooting
"Package not found" error
"Package not found" error
- Make sure your project targets .NET 10 or later.
Mellowtel.Winrequiresnet10.0. - Clear the NuGet cache and restore:
"InvalidOperationException: User has not opted in"
"InvalidOperationException: User has not opted in"
StartAsync() requires explicit consent. Call OptIn() after your consent dialog returns a positive result, then call StartAsync(). For silent resume on subsequent launches, use StartIfOptedInAsync() instead, which is a no-op when the user has not opted in.Estimated time to complete: 10-15 minutes. If you need help or have feedback, contact us at info@mellowtel.com or join our Discord community.