-
Notifications
You must be signed in to change notification settings - Fork 2
/
ConnectionProviderExtensions.vb
21 lines (19 loc) · 1.06 KB
/
ConnectionProviderExtensions.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Imports DevExpress.ReportServer.ServiceModel.Client
Imports DevExpress.ReportServer.ServiceModel.ConnectionProviders
Imports System
Imports System.Threading.Tasks
Namespace ScheduledTasksAPIClientDemo
Public Module ConnectionProviderExtensions
<System.Runtime.CompilerServices.Extension> _
Public Function DoWithScheduledJobAsync(Of T)(ByVal serverConnection As ConnectionProvider, ByVal func As Func(Of IReportServerClient, Task(Of T))) As Task(Of T)
Return serverConnection.ConnectAsync().ContinueWith(Function(taskFunc)
Dim client As IReportServerClient = taskFunc.Result
Return func(client)
End Function).Unwrap()
End Function
<System.Runtime.CompilerServices.Extension> _
Public Function DoWithScheduledJobAsync(ByVal serverConnection As ConnectionProvider, ByVal func As Func(Of IReportServerClient, Task)) As Task
Return serverConnection.ConnectAsync().ContinueWith(Function(task) func(task.Result)).Unwrap()
End Function
End Module
End Namespace