blob: 716f00d9c344859663123f4ce2d9da0027386813 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
' **********************************************************************
'
' Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
'
' This copy of Ice is licensed to you under the terms described in the
' ICE_LICENSE file included in this distribution.
'
' **********************************************************************
Imports Demo
Imports System
Imports System.Collections
Public Class QueueI
Inherits QueueDisp_
Public Overloads Overrides Sub get_async(ByVal cb As AMD_Queue_get, ByVal id As String, ByVal current As Ice.Current)
SyncLock Me
If not _messageQueue.Count = 0 Then
Try
cb.ice_response(_messageQueue(0))
_messageQueue.RemoveAt(0)
Catch ex As Ice.Exception
Console.Error.WriteLine(ex)
End Try
Else
Dim request As Request = New Request
request.id = id
request.cb = cb
_requestQueue.Add(request)
End If
End SyncLock
End Sub
Public Overloads Overrides Sub add(ByVal message As String, ByVal current As Ice.Current)
SyncLock Me
If not _requestQueue.Count = 0 Then
Try
Dim request As Request = _requestQueue(0)
request.cb.ice_response(message)
Catch ex As Ice.Exception
Console.Error.WriteLine(ex)
End Try
_requestQueue.RemoveAt(0)
Else
_messageQueue.Add(message)
End If
End SyncLock
End Sub
Public Overloads Overrides Sub cancel_async(ByVal cb As AMD_Queue_cancel, ByVal ids As String(), ByVal current As Ice.Current)
cb.ice_response()
SyncLock Me
For i As Integer = 0 To ids.Length
Dim r As Request
For Each r In _requestQueue
If r.id.Equals(ids(i)) Then
Try
r.cb.ice_exception(New RequestCanceledException())
Catch ex As Ice.Exception
' Ignore
End try
_requestQueue.Remove(r)
Exit For
End If
Next
Next
End SyncLock
End Sub
Private Class Request
Public id As String
Public cb As AMD_Queue_get
End Class
Private _messageQueue As ArrayList = New ArrayList
Private _requestQueue As ArrayList = New ArrayList
End Class
|