Oliver
2008-06-12 15:06:12 UTC
I'm at an impasse with my remoting code, and I am hoping that someone could
help me. I have a class for determining disk space usage on a remote
server, and in order to determine the disk space usage of a particular
folder, it has to do a loop and get the file length of all files. In some
cases, there are more than 80,000 files in all subfolders, and the process
takes more than 5 minutes to calculate on the server. It seems that there
is a threshold for the length of time this calculation takes that at a
specific point, it will no longer return the value to the client. Here is
the code I am using on the server side:
Server Side:
Public Class DiskSpaceUsage
Inherits MarshalByRefObject
Public Function Size(ByVal di As System.IO.DirectoryInfo) As Long
Dim total As Long = 0
For Each file As System.IO.FileInfo In di.GetFiles()
total += file.Length
Next
For Each dir As System.IO.DirectoryInfo In di.GetDirectories()
total += Size(dir)
Next
Return total
End Function
End Class
Client Side:
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Lifetime
Module Module1
Private mTcp As Tcp.TcpChannel
Sub Main()
Try
mTcp = New Tcp.TcpChannel(9000)
ChannelServices.RegisterChannel(mTcp, False)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(servertools.DiskSpaceUsage),
"DiskSpaceUsage", WellKnownObjectMode.SingleCall)
...
...
...
Dim FolderSize As DiskSpaceUsage =
CType(Activator.GetObject(GetType(DiskSpaceUsage), url & "DiskSpaceUsage"),
DiskSpaceUsage)
dim lFoldersize as long = foldersize.size(diFolder)
Catch ex as exception
End Try
End Sub
End Module
I've tried setting the GetLifetimeService and iLease to 30 minutes, and a
few other variables on the lifetimeservices, but nothing seems to work. I
set the server function to write to the console when it's complete, so I
know that the function completes successfully, but it does not return the
value. I'm not sure if the client has closed the connection at this point,
but it just hangs at the remote function call, and it does not let me
continue code execution, or error out, so there is no way for me to run a
client-side test on the connection.
Any help is appreciated, as I have looked everywhere to describe this
problem without success.
help me. I have a class for determining disk space usage on a remote
server, and in order to determine the disk space usage of a particular
folder, it has to do a loop and get the file length of all files. In some
cases, there are more than 80,000 files in all subfolders, and the process
takes more than 5 minutes to calculate on the server. It seems that there
is a threshold for the length of time this calculation takes that at a
specific point, it will no longer return the value to the client. Here is
the code I am using on the server side:
Server Side:
Public Class DiskSpaceUsage
Inherits MarshalByRefObject
Public Function Size(ByVal di As System.IO.DirectoryInfo) As Long
Dim total As Long = 0
For Each file As System.IO.FileInfo In di.GetFiles()
total += file.Length
Next
For Each dir As System.IO.DirectoryInfo In di.GetDirectories()
total += Size(dir)
Next
Return total
End Function
End Class
Client Side:
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Lifetime
Module Module1
Private mTcp As Tcp.TcpChannel
Sub Main()
Try
mTcp = New Tcp.TcpChannel(9000)
ChannelServices.RegisterChannel(mTcp, False)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(servertools.DiskSpaceUsage),
"DiskSpaceUsage", WellKnownObjectMode.SingleCall)
...
...
...
Dim FolderSize As DiskSpaceUsage =
CType(Activator.GetObject(GetType(DiskSpaceUsage), url & "DiskSpaceUsage"),
DiskSpaceUsage)
dim lFoldersize as long = foldersize.size(diFolder)
Catch ex as exception
End Try
End Sub
End Module
I've tried setting the GetLifetimeService and iLease to 30 minutes, and a
few other variables on the lifetimeservices, but nothing seems to work. I
set the server function to write to the console when it's complete, so I
know that the function completes successfully, but it does not return the
value. I'm not sure if the client has closed the connection at this point,
but it just hangs at the remote function call, and it does not let me
continue code execution, or error out, so there is no way for me to run a
client-side test on the connection.
Any help is appreciated, as I have looked everywhere to describe this
problem without success.