Silverlight异步递归

Silverlight异步递归,silverlight,wcf,Silverlight,Wcf,我需要在递归中收集的信息。 我有一个具有以下递归的wpf应用程序: public static int GetClusterTotalDocumentsCount(ref int count, int clusterID, int lastrunid) { List<Cluster> subclusters = DBHandler.GetSubClustersOperational(clusterID); if (su

我需要在递归中收集的信息。 我有一个具有以下递归的wpf应用程序:

public static int GetClusterTotalDocumentsCount(ref int count, int clusterID, int lastrunid)
        {

            List<Cluster> subclusters = DBHandler.GetSubClustersOperational(clusterID);
            if (subclusters.Count == 0)
                return count;

            foreach (Cluster subclutser in subclusters)
            {
                int temp = DBHandler.GetClusterDocumentsCount(subclutser.ID, 0);
                count += temp;
                GetClusterTotalDocumentsCount(ref count, subclutser.ID, 0);
            }

            return count;

        }
public static int GetClusterTotalDocumentsCount(ref int count,int clusterID,int lastrunid)
{
List subclusters=DBHandler.GetSubClustersOperational(clusterID);
if(subclusters.Count==0)
返回计数;
foreach(子集群中的集群子集群)
{
int temp=DBHandler.GetClusterDocumentsCount(subclutser.ID,0);
计数+=温度;
GetClusterTotalDocumentsCount(参考计数,子LUTSER.ID,0);
}
返回计数;
}

现在我希望在silverlight中也能做到这一点。我没有使用ADO.net,而是为数据使用WCF服务。问题是,调用现在是异步的,所以我不能使用这个递归。有什么想法吗?

想想你的解决方案-你想要递归远程操作吗?这意味着层次结构中每个集群都要单独往返到服务器!创建只返回total的服务操作怎么样?递归仍将在该操作的服务器端占据一席之地

编辑:

顺便说一句,递归(和顺序)进行数据库查询也是错误的方法。SQLServer2005和更新的版本本机支持递归查询,因此您应该检查它们,并使用CTE(公共表表达式)将调用封装在单个存储过程中,以在到数据库的单次往返中执行递归查询