
FileProgress event
Fires during file transfer.
Syntax
- C#
- C++
- VB.NET
delegate void devP2P.FileProgressEvent(IntPtr Handle, int chanid, Int64 position, Int64 size);
The FileProgress(Handle,chanid,position,size) syntax has these parts:
The FileProgress(Handle,chanid,position,size) syntax has these parts:
Handle | Reference to the devP2P instance. |
chanid | Index of the channel where file is being transferred. |
position | Current transfer position. |
size | Total size that will be transferred. |
void FileProgress(CP2P *p2p, int chanid, int64 position, int64 size);
The FileProgress(p2p,chanid,position,size) syntax has these parts:
The FileProgress(p2p,chanid,position,size) syntax has these parts:
p2p | Pointer to devP2P instance that fired the event. |
chanid | Index of the channel where file is being transferred. |
position | Current transfer position. |
size | Total size that will be transferred. |
Delegate Sub P2P_FileProgressEvent(ByVal Handle As IntPtr, ByVal chanid As Integer, ByVal position As Int64, ByVal size As Int64)
The FileProgress(Handle,chanid,position,size) syntax has these parts:
The FileProgress(Handle,chanid,position,size) syntax has these parts:
Handle | Reference to the devP2P instance. |
chanid | Index of the channel where file is being transferred. |
position | Current transfer position. |
size | Total size that will be transferred. |
Remarks
This event fires during file transfer, both when file is being sent and received. You can monitor it's progress and check current Bandwidth if you are interested in transfer speed. When transfer finishes, FileDone will be fired.To use this event, you should implement function by yourself in the code (based on function declaration), and set devP2P.Events.FileProgress structure member to point to your function.
Code sample
- C++
void p2p_FileProgress(devP2Plib::CP2P *p2p, int chanid, int64 position, int64 size)
{
printf("%s] Progress %ld/%ld (%d%%) bandwidth=%5.2f MB/sec\r\n", p2p->MyName, (long)position, (long)size, (int)((position*100)/size), p2p->Bandwidth(chanid));
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.FileProgress = p2p_FileProgress;
/* ... */
}
{
printf("%s] Progress %ld/%ld (%d%%) bandwidth=%5.2f MB/sec\r\n", p2p->MyName, (long)position, (long)size, (int)((position*100)/size), p2p->Bandwidth(chanid));
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.FileProgress = p2p_FileProgress;
/* ... */
}
Platforms
WindowsMac OSX
Linux
BSD