DataPlanStatus Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents current data plan status (limits, usage, cycle metadata) for a connection profile.
public ref class DataPlanStatus sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class DataPlanStatus final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class DataPlanStatus
Public NotInheritable Class DataPlanStatus
- Inheritance
- Attributes
Windows requirements
| Device family |
Windows 10 (introduced in 10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
Examples
Example (C#):
var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
var status = profile?.GetDataPlanStatus();
if (status?.DataPlanUsage != null && status.DataLimitInMegabytes.HasValue)
{
var used = status.DataPlanUsage.MegabytesUsed;
var limit = status.DataLimitInMegabytes.Value;
double pct = (double)used / limit;
if (pct > 0.8)
{
// Enter reduced bandwidth mode.
}
}
Example (C++/WinRT):
auto profile = Windows::Networking::Connectivity::NetworkInformation::GetInternetConnectionProfile();
auto status = profile ? profile.GetDataPlanStatus() : nullptr;
if (!status)
{
return; // No data plan info available.
}
auto usage = status.DataPlanUsage(); // May be null
auto limitRef = status.DataLimitInMegabytes(); // IReference<uint32_t>, may be null
if (usage && limitRef)
{
auto limit = limitRef.Value();
if (limit > 0) // Defensive: avoid divide-by-zero if a provider reports 0.
{
double pct = static_cast<double>(usage.MegabytesUsed()) / limit;
if (pct > 0.8)
{
// Enter reduced bandwidth mode
}
}
}
Remarks
Obtaining an instance
Call ConnectionProfile.GetDataPlanStatus on a profile obtained via:
- NetworkInformation.GetInternetConnectionProfile
- NetworkInformation.FindConnectionProfilesAsync
- NetworkInformation.GetConnectionProfiles
Null handling
Important
Always null-check the returned DataPlanStatus. Some profiles (for example unmanaged Wi-Fi hotspots) do not expose
plan information and return null.
Core elements
| Property | Meaning / Guidance |
|---|---|
| DataPlanUsage | Current measured usage (may lag real traffic) |
| DataLimitInMegabytes | Plan cap (nullable). Null => unspecified limit (do not assume unlimited). |
| MaxTransferSizeInMegabytes | Recommended maximum size for a single transfer (chunk large sync into segments). |
| NextBillingCycle | Start of next cycle (nullable). Do not assume calendar month boundaries. |
Quota logic guidelines
- Interpret
DataPlanUsagetogether withDataLimitInMegabytes. A missing limit means you cannot enforce a hard cap safely. - Use both percentage consumed and time remaining before throttling; early-cycle high usage does not always justify restriction.
- Treat missing
DataLimitInMegabytesas "unspecified" rather than "unlimited".
Transfer optimization
- Honor
MaxTransferSizeInMegabytesby batching work into chunks at or below the recommendation. - For background sync on metered or limited plans, schedule incremental commits instead of monolithic uploads.
Billing cycle handling
NextBillingCyclemay be absent; fall back to rolling usage display without reset logic.- When present, derive remaining quota window precisely; operators define custom cycle boundaries.
Fallback behavior
If DataPlanStatus is null or critical fields are missing:
- Present generic usage UI without enforcement.
- Allow user override for "treat as metered" or "treat as unrestricted" preferences if your app supports it.
Note
Defensive coding: Providers can report unexpected values (like zero or very small MaxTransferSizeInMegabytes). Clamp
to sensible minimums before applying heuristics.
Properties
| DataLimitInMegabytes |
Gets a value indicating the maximum data transfer allowance for a connection within each billing cycle, as defined by the data plan. |
| DataPlanUsage |
Gets a DataPlanUsage object that indicates the amount of data transferred over the connection, in megabytes, and the last time this value was refreshed. |
| InboundBitsPerSecond |
Gets a value indicating the nominal rate of the inbound data transfer occurring on the connection. |
| MaxTransferSizeInMegabytes |
Gets a value indicates the maximum size of a transfer that is allowed without user consent on a metered network. |
| NextBillingCycle |
Gets a value indicating the date and time of the next billing cycle. |
| OutboundBitsPerSecond |
Gets a value indicating the nominal rate of the outbound data transfer. |