Asynchronous communication and IDictionary....

R

Robin Mark Tucker

Hi,


Please forgive me I'm completely new to ASP.NET, having just setup a service
yesterday for testing/playing around at work. I have a fat client at the
moment that contains an abstract DataConnection class. Derived from that I
have SQLServerDataConnection, OracleDataConnection, MySQLDataConnection,
etc. I'm hoping to add ASPNETDataConnection to the list of connections the
factory can return, but I've got a few questions about how best to implement
this.

Firstly, I can't use many of the classes I implement and manipulate in my
disconnected cache. It seems ASPNET doesn't like serializing IDictionary
for instance. I suppose I can get around this by creating my own "proxy"
class, that takes the data in some other format and creates the various
required collections, but perhaps there is a way of giving a class suitable
attributes to enable ASPNET to receive and return these types in it's own
generated code?

As an example, I have an enumeration called "ConditionEnum":


Public Enum ConditionEnum

Green
Yellow
Red
Undefined

End Enum


I then have another class that hashes an integer key (a record primary key
in the database) to a given Condition:


Public Class ConditionsHash

Inherits Dictionary (Of Integer, ConditionEnum)

...
End Class


One of the methods on my data connection class returns a ConditionsHash
object:


Public Function GetConditions (ByRef theConditionsHash As ConditionsHash) As
DataError

...
...
Return theConditionsHash

End Function


Now it appears my project fails to generate a proxy for ConditionsHash
because it derives from IDictionary. What is the preferred solution in this
case?



Secondly, if I kick off an operation that might take some time (say,
processing 1,000 records in a database), how do I notify the client of my
progress? I don't want the service to be too chatty, so I don't want to
have to send 1,000 requests when I can send 1 collection of keys to process
in 1 request. Is it a question of the client executing another method on
the service ("GetItemsCompleted() As Integer")? Are calls like this queued
and executed in turn? ie. will ASPNET finish the method call that processes
the records and then execute GetItemsCompleted? Alternatively, is there a
callback mechanism available to enable the service class to fire a
"ItemCompleted" event on the proxy after each of it's iterations, ie.:

<WebMethod()>_
Public Sub ExecuteBatch (ByVal theIntegers As ArrayList)


For i as Integer = 0 To theIntegers.Count - 1


' Perform some random action....

DoSomethingWithTheInteger (i)



' Raise completed event to the client for every 10 we process.

If (i Mod 10) = 0 Then
RaiseEvent Progress ( i )
End if


Next

End Sub



Thanks for your insights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top