-api-id | -api-type |
---|---|
M:Windows.Networking.Sockets.StreamSocket.TransferOwnership(System.String) |
winrt method |
Transfers ownership of the StreamSocket to the socket brokering service, which monitors socket activity and notifies the app through a background task if there is any activity.
A string the app uses to identify the transferred socket. The string should identify this socket uniquely within the app. When activity occurs on this socket, this string will be provided to the app to identify the socket.
Your app should call this method to transfer ownership of the StreamSocket to the socket brokering service when the app is about to be suspended, or at the end of a background task. Your app should not access the StreamSocket object after calling this method, except when responding to notifications from the socket brokering service.
Note
This call fails if there is any pending I/O on the StreamSocket. Your code should call StreamSocket.CancelIOAsync to cancel any further new traffic, then handle all pending traffic, and then update the SocketActivityContext, before calling StreamSocket.TransferOwnership.
TransferOwnership(String, SocketActivityContext), TransferOwnership(String, SocketActivityContext, TimeSpan)