【问题标题】:Restart application required to update information更新信息所需的重新启动应用程序
【发布时间】:2022-01-13 09:54:43
【问题描述】:

我有一个 mvc 模式的 windows 窗体应用程序,我有一个控制器调用来检索我需要的信息,在这种情况下,如果应用程序移动被终止。

控制器调用通常是这样完成的:

_listMoviment = new MovimentController().GetRelationMoviment(UserLogged.companyCode);

在控制器上调用此方法:

    public List<Moviment> GetRelationMoviment(short companyCode)
    {
        return RepositorioBase.GetRelationMoviment(companyCode);
    }

顺便在存储库中调用了这个方法:

    public List<Moviment> GetRelationMoviment(short companyCode)
    {
        return EntityRepository.Include(x => x.Operator)
                                  .Where(x => x.CompanyCode == companyCode &&
                                              x.CompanyCodeMoviment == null)
                                  .ToList();

    }

而且这个流程工作正常,但是如果我重新启动应用程序,它只会更新信息,有什么方法可以强制更新而无需重新启动?

【问题讨论】:

    标签: c# winforms linq model-view-controller entity-framework-6


    【解决方案1】:

    将数据重新写入 Windows 窗体后,您需要重新绘制窗体以更新数据。

    看看这个链接here应该解释如何刷新。您必须在 API 调用完成后放置它,否则您可能会遇到问题,即它会刷新并且由于正在进行的 API 调用而没有任何显示。

    这些链接也可能对您有所帮助:

    【讨论】:

    • 我在控制器调用后应用了刷新,但它不起作用
    • 并且我验证了即使我之前放了它,我的控制器也会不断返回旧值
    • 您是否使当前数据无效? The Invalidate method governs what gets painted or repainted. The Update method governs when the painting or repainting occurs. If you use the Invalidate and Update methods together rather than calling Refresh. [...] The Update method just forces the control to be painted immediately, but the Invalidate method governs what gets painted when you call the Update method. - docs.microsoft.com/en-us/dotnet/api/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 2012-05-30
    • 1970-01-01
    • 1970-01-01
    • 2011-08-10
    • 2015-12-03
    相关资源
    最近更新 更多