Class ProgressEvent
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The ProgressEvent interface represents events that measure the progress of an underlying process, like an HTTP request (e.g., an XMLHttpRequest, or the loading of the underlying resource of an img, audio, video, style or link).
[Value("ProgressEvent")]
public class ProgressEvent : Event
- Inheritance
-
ProgressEvent
- Inherited Members
Remarks
-The Event base interface.
Constructors
ProgressEvent()
public ProgressEvent()
ProgressEvent(string, ProgressEventInit)
The ProgressEvent() constructor returns a new ProgressEvent object, representing the current completion of a long process.
public ProgressEvent(string type, ProgressEventInit eventInitDict = null)
Parameters
typestringeventInitDictProgressEventInit
Remarks
-The ProgressEvent interface it belongs to.
Properties
LengthComputable
TheProgressEvent.lengthComputable read-only property is a
boolean flag indicating if the resource concerned by the
ProgressEvent has a length that can be calculated. If not, the
Total property has no significant value.
[Value("lengthComputable")]
public bool LengthComputable { get; }
Property Value
- bool
A boolean.
Remarks
-The ProgressEvent interface it belongs to.
Loaded
The ProgressEvent.loaded read-only property is a number indicating the size of the data already transmitted or processed.
The progress ratio can be calculated by dividing the value of this property by Total.
[Value("loaded")]
public ulong Loaded { get; }
Property Value
- ulong
A number.
Remarks
For ProgressEvents dispatched by the browser in HTTP messages, the value refers to the amount of bytes of a resource that are completed, and is derived from the Content-Length header.
For compressed requests of unknown total size, loaded might contain the size of the compressed or decompressed data, depending on the browser.
As of 2024, it contains the size of the compressed data in Firefox, and the size of the uncompressed data in Chrome.
In a ProgressEvent you create yourself, you can assign any numeric value to loaded that represents the amount of work completed relative to the total value.
-The ProgressEvent interface it belongs to.
Total
The ProgressEvent.total read-only property is a number indicating the total size of the data being transmitted or processed.
[Value("total")]
public ulong Total { get; }
Property Value
- ulong
A number.
Remarks
For ProgressEvents dispatched by the browser, the value refers to the size, in bytes, of a resource and is derived from the Content-Length response header.
In a ProgressEvent you create yourself, this may also be the total bytes of a resource, although this can be any number.
For example, you may wish to normalize total to a value such as 100 or 1 if revealing the precise amount of bytes of a resource is a concern.
If using 1 as a total, then Loaded would be a decimal value between 0 and 1.
If the event's LengthComputable property is false, this value is meaningless and should be ignored.
-The ProgressEvent interface it belongs to.