Permalink
Browse files

Fixing 'not awaited' warnings...

  • Loading branch information...
Strilanc committed Jun 6, 2012
1 parent 808e307 commit 16dd9716e24241e36d1cc465d51e2380220af12a
@@ -225,7 +225,7 @@ Namespace Bnet.Commands
Try
'Link user to gameSet
If user IsNot Nothing Then
- target.QueueSetUserGameSet(user, gameSet)
+ Call Async Sub() Await target.QueueSetUserGameSet(user, gameSet)
gameSet.ChainEventualDisposalTo(Sub() target.QueueResetUserGameSet(user, gameSet))
End If
@@ -234,7 +234,7 @@ Namespace Bnet.Commands
onStarted = Sub(sender, active)
If active Then Return
RemoveHandler gameSet.StateChanged, onStarted
- target.Client.ExcludeAdvertisableGameAsync(gameSet.GameSettings.GameDescription)
+ Call Async Sub() Await target.Client.ExcludeAdvertisableGameAsync(gameSet.GameSettings.GameDescription)
End Sub
AddHandler gameSet.StateChanged, onStarted
@@ -133,7 +133,7 @@ Namespace Bnet
Return 'not a message
ElseIf text = Tinker.Bot.MainBot.TriggerCommandText Then '?trigger command
If user.Name.Length <= 0 Then Throw New InvalidStateException("Empty user name.")
- _client.SendWhisperAsync(user.Name, "Command prefix: {0}".Frmt(My.Settings.commandPrefix))
+ Call Async Sub() Await _client.SendWhisperAsync(user.Name, "Command prefix: {0}".Frmt(My.Settings.commandPrefix))
Return
ElseIf Not text.StartsWith(commandPrefix, StringComparison.OrdinalIgnoreCase) Then 'not a command
Return 'not a command
@@ -149,15 +149,15 @@ Namespace Bnet
Call Async Sub()
Await _client.Clock.Delay(2.Seconds)
If Not finishedLock.TryAcquire Then Return
- _client.SendWhisperAsync(user.Name, "Command '{0}' is running...".Frmt(text))
+ Call Async Sub() Await _client.SendWhisperAsync(user.Name, "Command '{0}' is running...".Frmt(text))
End Sub
'Await result
Dim message = Await commandResult
finishedLock.TryAcquire()
- _client.SendWhisperAsync(user.Name, If(message, "Command Succeeded"))
+ Call Async Sub() Await _client.SendWhisperAsync(user.Name, If(message, "Command Succeeded"))
Catch ex As Exception
- _client.SendWhisperAsync(user.Name, "Failed: {0}".Frmt(ex.Summarize))
+ Call Async Sub() Await _client.SendWhisperAsync(user.Name, "Failed: {0}".Frmt(ex.Summarize))
End Try
End Function
@@ -170,14 +170,12 @@ Namespace Bnet
If slaved Then
_autoHook = _bot.ObserveGameSets(
- adder:=Sub(server, gameSet)
+ adder:=Async Sub(server, gameSet)
If gameSet.GameSettings.IsAdminGame Then Return
- _client.IncludeAdvertisableGameAsync(gameDescription:=gameSet.GameSettings.GameDescription,
- isPrivate:=gameSet.GameSettings.IsPrivate)
+ Await _client.IncludeAdvertisableGameAsync(gameDescription:=gameSet.GameSettings.GameDescription,
+ isPrivate:=gameSet.GameSettings.IsPrivate)
End Sub,
- remover:=Sub(server, gameSet)
- _client.ExcludeAdvertisableGameAsync(gameSet.GameSettings.GameDescription)
- End Sub)
+ remover:=Async Sub(server, gameSet) Await _client.ExcludeAdvertisableGameAsync(gameSet.GameSettings.GameDescription))
Else
Dim oldHook = _autoHook
_autoHook = Nothing
@@ -232,7 +230,7 @@ Namespace Bnet
Protected Overrides Function PerformDispose(finalizing As Boolean) As Task
_client.Dispose()
- _control.DisposeControlAsync()
+ Call Async Sub() Await _control.DisposeControlAsync()
Return _hooks.DisposeAllAsync()
End Function
End Class
View
@@ -279,7 +279,7 @@ Namespace Bnet
For Each line In lines
Contract.Assume(line IsNot Nothing)
If line.Length = 0 Then Continue For
- TrySendPacketAsync(Protocol.MakeChatCommand(line))
+ Call Async Sub() Await TrySendPacketAsync(Protocol.MakeChatCommand(line))
Next line
End Function
@@ -298,14 +298,14 @@ Namespace Bnet
For Each line In SplitText(text, maxLineLength:=Protocol.Packets.ClientToServer.MaxChatCommandTextLength - prefix.Length)
Contract.Assume(line IsNot Nothing)
- TrySendPacketAsync(Protocol.MakeChatCommand(prefix + line))
+ Call Async Sub() Await TrySendPacketAsync(Protocol.MakeChatCommand(prefix + line))
Next line
End Function
Private Sub SetReportedListenPortPresync(port As UShort)
If port = Me._reportedListenPort Then Return
Me._reportedListenPort = port
- TrySendPacketAsync(Protocol.MakeNetGamePort(Me._reportedListenPort.Value))
+ Call Async Sub() Await TrySendPacketAsync(Protocol.MakeNetGamePort(Me._reportedListenPort.Value))
End Sub
Protected Overrides Function PerformDispose(finalizing As Boolean) As Task
@@ -347,7 +347,7 @@ Namespace Bnet
End Sub()
Loop
Catch ex As Exception
- DisconnectAsync(expected:=False, reason:="Error receiving packet: {0}".Frmt(ex.Summarize))
+ Call Async Sub() Await DisconnectAsync(expected:=False, reason:="Error receiving packet: {0}".Frmt(ex.Summarize))
End Try
End Sub
@@ -415,7 +415,7 @@ Namespace Bnet
ChangeStatePresync(ClientState.EnterUserCredentials)
End Using
Catch ex As Exception
- DisconnectAsync(expected:=False, reason:="Failed to complete connection: {0}.".Frmt(ex.Summarize))
+ Call Async Sub() Await DisconnectAsync(expected:=False, reason:="Failed to complete connection: {0}.".Frmt(ex.Summarize))
Throw
End Try
End Function
@@ -475,10 +475,10 @@ Namespace Bnet
'Forward bnls to bnet warden
Try
- Await bnlsSocket.QueueRunAsync(ct, Sub(data) TrySendPacketAsync(Protocol.MakeWarden(data)))
+ Await bnlsSocket.QueueRunAsync(ct, Async Sub(data) Await TrySendPacketAsync(Protocol.MakeWarden(data)))
Catch ex As Exception
ex.RaiseAsUnexpected("Warden/BNLS Error")
- DisconnectAsync(expected:=False, reason:="Warden/BNLS Error: {0}.".Frmt(ex.Summarize))
+ Call Async Sub() Await DisconnectAsync(expected:=False, reason:="Warden/BNLS Error: {0}.".Frmt(ex.Summarize))
End Try
End Sub
@@ -545,7 +545,7 @@ Namespace Bnet
await inQueue
If _socket IsNot Nothing Then
- _socket.QueueDisconnect(expected, reason)
+ Call Async Sub() Await _socket.QueueDisconnect(expected, reason)
_socket = Nothing
ElseIf _state = ClientState.Disconnected Then
Return
@@ -558,7 +558,7 @@ Namespace Bnet
ChangeStatePresync(ClientState.Disconnected)
Logger.Log("Disconnected ({0})".Frmt(reason), LogMessageType.Negative)
- If Not expected Then TryReconnectPresync()
+ If Not expected Then Call Async Sub() Await TryReconnectPresync()
End Function
Private Async Function TryReconnectPresync() As Task(Of Boolean)
If _state <> ClientState.Disconnected Then Return False
@@ -582,7 +582,7 @@ Namespace Bnet
End Function
Private Sub EnterChannelPresync(channel As InvariantString)
- TrySendPacketAsync(Protocol.MakeJoinChannel(Protocol.JoinChannelType.ForcedJoin, channel))
+ Call Async Sub() Await TrySendPacketAsync(Protocol.MakeJoinChannel(Protocol.JoinChannelType.ForcedJoin, channel))
ChangeStatePresync(ClientState.Channel)
TryStartAdvertisingPresync()
End Sub
@@ -591,7 +591,7 @@ Namespace Bnet
If _curAdvertisement Is Nothing Then Return
If _advertisementList.Contains(_curAdvertisement) Then Return
- TrySendPacketAsync(Protocol.MakeCloseGame3())
+ Call Async Sub() Await TrySendPacketAsync(Protocol.MakeCloseGame3())
_curAdvertisement = Nothing
_gameCanceller.Cancel()
EnterChannelPresync(_lastChannel)
@@ -620,7 +620,7 @@ Namespace Bnet
_curAdvertisement.IncreaseNameFailCount()
Loop
_curAdvertisement.TryMarkAsSucceeded()
- outQueue.QueueAction(Sub() RaiseEvent AdvertisedGame(Me, _curAdvertisement.GetCurrentCandidateGameDescriptionWithFixedAge(), _curAdvertisement.IsPrivate, refreshed:=False))
+ Call Async Sub() Await outQueue.QueueAction(Sub() RaiseEvent AdvertisedGame(Me, _curAdvertisement.GetCurrentCandidateGameDescriptionWithFixedAge(), _curAdvertisement.IsPrivate, refreshed:=False))
'Refresh game periodically
ChangeStatePresync(ClientState.AdvertisingGame)
@@ -642,7 +642,7 @@ Namespace Bnet
EnterChannelPresync(_lastChannel)
Exit Do
End If
- outQueue.QueueAction(Sub() RaiseEvent AdvertisedGame(Me, _curAdvertisement.GetCurrentCandidateGameDescriptionWithFixedAge(), _curAdvertisement.IsPrivate, refreshed:=True))
+ Call Async Sub() Await outQueue.QueueAction(Sub() RaiseEvent AdvertisedGame(Me, _curAdvertisement.GetCurrentCandidateGameDescriptionWithFixedAge(), _curAdvertisement.IsPrivate, refreshed:=True))
Loop
End Sub
@@ -700,7 +700,7 @@ Namespace Bnet
_socket.WritePacket({Protocol.Packets.PacketPrefixValue, id}, payload.Data)
Return True
Catch ex As Exception
- DisconnectAsync(expected:=False, reason:="Error sending {0} to {1}: {2}".Frmt(id, _socket.Name, ex.Summarize))
+ Call Async Sub() Await DisconnectAsync(expected:=False, reason:="Error sending {0} to {1}: {2}".Frmt(id, _socket.Name, ex.Summarize))
ex.RaiseAsUnexpected("Error sending {0} to {1}".Frmt(id, _socket.Name))
Return False
End Try
View
@@ -46,7 +46,7 @@ Namespace Bot.Commands
Dim clientComponent = Await Bnet.ClientComponent.FromProfileAsync(profileName, profileName, _clock, parent)
Try
- clientComponent.QueueSetAutomatic(True)
+ Call Async Sub() Await clientComponent.QueueSetAutomatic(True)
Await parent.Components.QueueAddComponent(clientComponent)
Dim client = clientComponent.Client
Dim profile = client.Profile
@@ -147,7 +147,7 @@ Namespace Bot.Commands
Dim clientComponent = Await Bnet.ClientComponent.FromProfileAsync(clientName, profileName, _clock, target)
Try
Await target.Components.QueueAddComponent(clientComponent)
- If argument.HasOptionalSwitch("auto") Then clientComponent.QueueSetAutomatic(True)
+ If argument.HasOptionalSwitch("auto") Then Call Async Sub() Await clientComponent.QueueSetAutomatic(True)
Return "Created Client"
Catch ex As Exception
clientComponent.Dispose()
@@ -179,7 +179,7 @@ Namespace Bot.Commands
Dim advertiser = New Lan.UDPAdvertiser(New CachedWC3InfoProvider(), _clock, remoteHost)
Dim advertiserComponent = New Lan.UDPAdvertiserComponent(name, target, advertiser)
Try
- If auto Then advertiserComponent.QueueSetAutomatic(auto)
+ If auto Then Call Async Sub() Await advertiserComponent.QueueSetAutomatic(auto)
Await target.Components.QueueAddComponent(advertiserComponent)
Return "Created lan advertiser."
Catch ex As Exception
View
@@ -63,7 +63,7 @@ Namespace Bot
End Function
Protected Overrides Function PerformDispose(finalizing As Boolean) As Task
_bot.Dispose()
- _control.DisposeControlAsync()
+ Call Async Sub() Await _control.DisposeControlAsync()
Return Nothing
End Function
View
@@ -43,7 +43,7 @@ Namespace CKL
Dim packet = Await socket.AsyncReadPacket
Dim result = ParseResponse(packet)
- socket.QueueDisconnect(expected:=True, reason:="Finished")
+ Call Async Sub() Await socket.QueueDisconnect(expected:=True, reason:="Finished")
_logger.Log("Succesfully borrowed keys from CKL server.", LogMessageType.Positive)
Return result
Catch ex As Exception
@@ -26,7 +26,7 @@ Namespace CKL
Protected Overrides Function PerformDispose(finalizing As Boolean) As Task
_server.Stop()
- _control.DisposeControlAsync()
+ Call Async Sub() Await _control.DisposeControlAsync()
Return Nothing
End Function
@@ -247,8 +247,8 @@ Public Class DownloadManagerTest
dler.InjectClientMapInfo(MapTransferState.Idle, 0)
uler.InjectClientMapInfo(MapTransferState.Idle, game.Map.FileSize)
- dler.InjectReceivedPacket(MakePeerConnectionInfo({uler.ID}))
- uler.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID}))
+ Call Async Sub() Await dler.InjectReceivedPacket(MakePeerConnectionInfo({uler.ID}))
+ Call Async Sub() Await uler.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID}))
uler.ExpectNoPacket()
dler.ExpectNoPacket()
clock.Advance(Download.Manager.UpdatePeriod)
@@ -280,8 +280,8 @@ Public Class DownloadManagerTest
dler.InjectClientMapInfo(MapTransferState.Idle, 0)
uler.InjectClientMapInfo(MapTransferState.Idle, 0)
- dler.InjectReceivedPacket(MakePeerConnectionInfo({uler.ID}))
- uler.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID}))
+ Call Async Sub() Await dler.InjectReceivedPacket(MakePeerConnectionInfo({uler.ID}))
+ Call Async Sub() Await uler.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID}))
clock.Advance(Download.Manager.UpdatePeriod)
uler.ExpectNoPacket()
@@ -325,7 +325,7 @@ Public Class DownloadManagerTest
WaitUntilTaskSucceeds(game.AddPlayer(uler1))
dler.InjectClientMapInfo(MapTransferState.Idle, 0)
uler1.InjectClientMapInfo(MapTransferState.Idle, game.Map.FileSize)
- dler.InjectReceivedPacket(MakePeerConnectionInfo({uler1.ID}))
+ Call Async Sub() Await dler.InjectReceivedPacket(MakePeerConnectionInfo({uler1.ID}))
WaitUntilTaskSucceeds(uler1.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID})))
uler1.ExpectNoPacket()
dler.ExpectNoPacket()
@@ -340,7 +340,7 @@ Public Class DownloadManagerTest
'Cancel and start new transfer
WaitUntilTaskSucceeds(game.AddPlayer(uler2))
uler2.InjectClientMapInfo(MapTransferState.Idle, game.Map.FileSize)
- uler2.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID}))
+ Call Async Sub() Await uler2.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID}))
WaitUntilTaskSucceeds(dler.InjectReceivedPacket(MakePeerConnectionInfo({uler1.ID, uler2.ID})))
clock.Advance(Download.Manager.FreezePeriod)
dler.ExpectNoPacket()
@@ -385,7 +385,7 @@ Public Class DownloadManagerTest
WaitUntilTaskSucceeds(game.AddPlayer(uler1))
dler.InjectClientMapInfo(MapTransferState.Idle, 0)
uler1.InjectClientMapInfo(MapTransferState.Idle, game.Map.FileSize)
- dler.InjectReceivedPacket(MakePeerConnectionInfo({uler1.ID}))
+ Call Async Sub() Await dler.InjectReceivedPacket(MakePeerConnectionInfo({uler1.ID}))
WaitUntilTaskSucceeds(uler1.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID})))
uler1.ExpectNoPacket()
dler.ExpectNoPacket()
@@ -400,8 +400,8 @@ Public Class DownloadManagerTest
'Add second peer
WaitUntilTaskSucceeds(game.AddPlayer(uler2))
uler2.InjectClientMapInfo(MapTransferState.Idle, game.Map.FileSize)
- uler2.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID}))
- dler.InjectReceivedPacket(MakePeerConnectionInfo({uler1.ID, uler2.ID}))
+ Call Async Sub() Await uler2.InjectReceivedPacket(MakePeerConnectionInfo({dler.ID}))
+ Call Async Sub() Await dler.InjectReceivedPacket(MakePeerConnectionInfo({uler1.ID, uler2.ID}))
'Go slowly
Dim dt = Download.Manager.MinSwitchPeriod
View
@@ -155,7 +155,7 @@ Public NotInheritable Class PacketSocket
'Contract.Ensures(Contract.Result(Of Task(Of IRist(Of Byte)))() IsNot Nothing)
Try
Dim data = Await packetStreamer.AsyncReadPacket()
- If deadManSwitch IsNot Nothing Then deadManSwitch.QueueReset()
+ If deadManSwitch IsNot Nothing Then Call Async Sub() Await deadManSwitch.QueueReset()
Logger.Log(Function() "Received from {0}: {1}".Frmt(Name, data.ToHexString), LogMessageType.DataRaw)
Return data
Catch ex As Exception
@@ -51,12 +51,11 @@ Namespace WC3
Contract.Assume(sender IsNot Nothing)
Contract.Assume(slots IsNot Nothing)
Dim descriptions = Await Task.WhenAll(From slot In slots Select slot.AsyncGenerateDescription)
- inQueue.QueueAction(Sub()
- If IsDisposed Then Return
- For Each i In descriptions.Length.Range
- lstSlots.Items(i) = descriptions(i)
- Next i
- End Sub)
+ Await inQueue
+ If IsDisposed Then Return
+ For Each i In descriptions.Length.Range
+ lstSlots.Items(i) = descriptions(i)
+ Next i
End Sub
End Class
End Namespace
Oops, something went wrong.

0 comments on commit 16dd971

Please sign in to comment.