0

如何延迟 WCF 服务中的进程?

我在 WCF 应用程序中添加了一个额外的新服务。在 WCF 服务中调用方法时,会打开数据库并执行 LINQ 查询。但现在有了额外的服务。LINQ 查询不再起作用。我已经调试出了什么问题。我看到当我在方法中退后一步(通过调试)时,我两次调用 LINQ 查询,然后第二次查询就正确了。在打开数据库和执行查询之间的过程中必须添加延迟。但是怎么做?

谁能告诉我该怎么做?

谢谢...

在服务中:

namespace MHcService
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class ArtiestService : IArtiestService
    {
...
        public ArtiestRecord[] GetArtiestlijst(out ResultClass AResult, int AID_Genre, string AFilter)
        {
            Databeheer FDatabeheer = Databeheer.GetInstance();
            return ArtiestlijstToArray(ArtiestDataManager.Artiestlijst(out AResult, AID_Genre, AFilter));
        }

namespace MHcService.Database
{
    public static class DatabaseControl
    {
        private static Databeheer FDatabeheer = Databeheer.GetInstance();
        public static Databeheer GetDatabeheer { get { return FDatabeheer; } }
    }

    public class Databeheer
    {
...
        public DatamodelDataContext DataContext { get { return FDataContext; } }
        private static Databeheer FUniqueInstance;
        private static object FLockObject = new object();
        public static Databeheer GetInstance()
        {
            if (FUniqueInstance == null)
            {
                lock (FLockObject)
                {
                    if (FUniqueInstance == null)
                    {
                        FUniqueInstance = new Databeheer();
                    }
                }
            }

            return FUniqueInstance;
        }

        private Databeheer()
        {
            Initialize();
        }

        private void Initialize()
        {
            FApplicatieDefinities = ApplicatieDefinities.GetInstance();
            FApplicatieDefinities.Read();

            FDatabasenaam = FApplicatieDefinities.ParamsApplicatie.Databasenaam;
            FPadnaam = FApplicatieDefinities.ParamsApplicatie.Directories[DirectoryIndex.iDIR_DATABASE];
            FServernaam = FApplicatieDefinities.ParamsApplicatie.Servernaam;
            FDbBestandsnaam = FDatabasenaam + ConstAlgemeen.sEXT_MDF;
            FLogBestandsnaam = FDatabasenaam + "_LOG" + ConstAlgemeen.sEXT_LDF;
            FConnectionToSql = new SqlConnection(SqlServerConnectieString);
            FDataContext = new DatamodelDataContext(GetSqlServerConnectie());
        }

方法的链接<= 这是方法的来源(LINQ 查询) 通过这个问题,我没有得到想要阅读的答案。所以我不想展示这个问题的来源。

4

0 回答 0