Share via


ConnectivityInterval Class

Definition

Represents a contiguous connectivity span (start timestamp plus duration) for a connection profile.

public ref class ConnectivityInterval sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class ConnectivityInterval final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ConnectivityInterval
Public NotInheritable Class ConnectivityInterval
Inheritance
Object Platform::Object IInspectable ConnectivityInterval
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

Enumerate recent connectivity intervals (C#):

var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
if (profile != null)
{
    var end = DateTime.UtcNow;
    var start = end - TimeSpan.FromHours(6);
    var states = new Windows.Networking.Connectivity.NetworkUsageStates(); // unconstrained
    var intervals = await profile.GetConnectivityIntervalsAsync(start, end, states);
    foreach (var iv in intervals)
    {
        // iv.StartTime; iv.ConnectionDuration
    }
}

Remarks

Definition

A ConnectivityInterval captures a span during which the interface for a ConnectionProfile was in a connected state.

Characteristics

  • Presence vs. volume: Indicates connectivity existed; does not convey bytes transferred. Pair with GetNetworkUsageAsync for volume metrics.
  • Gaps: Sleep, interface transitions, or disconnections create gaps. Do not assume continuous coverage.
  • Partial boundaries: Leading/trailing intervals may be truncated when the query window cuts through an active connection.
  • Coalescing: Very brief disconnects may be hidden by higher-level accounting; sub-second precision should not be assumed.
  • History limits: Subject to the same retention constraints as usage APIs (for example, ~60 days).

Typical workflow

  1. Query intervals with GetConnectivityIntervalsAsync by supplying start, end, and states values.
  2. (Optional) Query usage over the same window.
  3. Correlate intervals and usage buckets to derive connected-but-idle versus active transfer periods.

Edge cases

Case Interpretation
Empty list No recorded connectivity in window (not an error)
Overlapping stitched windows Deduplicate by interval start time when merging
Long active interval May span entire query window; still valid

Incremental collection

Persist the end timestamp of the last fully closed interval. On the next run, start from that point to avoid recounting an interval still in progress.

Performance

Summarize promptly. Retaining large raw lists offers little value after computing aggregate connected duration or utilization.

Note

To compute utilization, sum ConnectionDuration across intervals and divide by total wall-clock span, then overlay usage to calculate bytes per connected minute.

Properties

ConnectionDuration

Length of this connectivity interval.

StartTime

Start timestamp of this connectivity interval.

Applies to

See also