RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-16416

Alex Krass's questions

Martin Hope
Alex Krass
Asked: 2020-11-18 05:10:25 +0000 UTC

Visual Studio 2017 - Css 编辑器 - 组件错误

  • -1

在工作室中打开 CSS 文件时,出现组件错误,编辑器敲掉标记。

在此处输入图像描述

ActivityLog.xml 日志文件包含以下信息。

  <entry>
    <record>746</record>
    <time>2017/11/17 18:49:57.319</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>
        System.ArgumentNullException: Value cannot be null.
        Parameter name: value
        at System.Enum.ToObject(Type enumType, Object value)
        at Microsoft.VisualStudio.Shell.DialogPage.SetPropertyValue(PropertyDescriptor descriptor, Object automationObject, Object value)
        at Microsoft.VisualStudio.Shell.DialogPage.LoadSettingFromStorage(PropertyDescriptor prop)
        at Microsoft.VisualStudio.Shell.DialogPage.LoadSettingsFromStorage()
        at Microsoft.VisualStudio.Shell.DialogPage.set_Site(ISite value)
        at System.ComponentModel.Container.Add(IComponent component, String name)
        at System.ComponentModel.Container.Add(IComponent component)
        at Microsoft.VisualStudio.Shell.Package.GetDialogPage(Type dialogPageType)
        at Microsoft.VisualStudio.Html.Package.Package.CSS.CssPackage.GetAutomationObject(String name)
        at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.GetAutomationObject(String propName, Object&amp; auto)
        at Microsoft.VisualStudio.Web.Editor.Package.Settings.Common.WebSettingsStorageWithDialog.LoadFromStorage()
        at Microsoft.Web.Editor.Host.WebEditor.GetSettings(String contentTypeName)
        at Microsoft.CSS.Editor.Settings.CssSettings.get_Storage()         
        at Microsoft.CSS.Editor.Settings.CssSettings.get_ValidationEnabled()
        at Microsoft.CSS.Editor.Checker.CssErrorTagger..ctor(ITextBuffer textBuffer)
        at Microsoft.CSS.Editor.Checker.CssErrorTagger.Attach(ITextBuffer textBuffer)
        at Microsoft.CSS.Editor.Checker.CssErrorTaggerProvider.CreateTagger[T](ITextBuffer textBuffer)
        at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)
        --- End of stack trace from previous location where exception was thrown ---   
        at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
    </description>
  </entry>

好吧,编辑器页面显示错误。

在此处输入图像描述

我尝试禁用和启用组件以使用 ASP.NET,包括 CSS 组件,但没有成功。试图恢复,再次没有。任何想法如何解决这一问题?

visual-studio
  • 2 个回答
  • 10 Views
Martin Hope
Alex Krass
Asked: 2020-10-31 18:43:56 +0000 UTC

如何杀死长时间运行的任务?

  • 3

有一个查询最多可能需要一个小时才能完成。为了不阻塞用户界面,它通过任务。如果用户厌倦了等待,这个请求应该被取消。如何正确地做到这一点,以便连接不会在加载数据库时挂起一个小时,并且用户不会创建一堆它们?也许除了任务之外还有其他选择?

private void UpdateGrid(){
    SomeRows rows;
    Task task = new Task(() => 
    {
        rows = IDBConnectInstance.SelectRows();
    });
    task.ContinueWith(() =>
    {
        dataGridView.DataSource = rows;
    }, TaskScheduler.FromCurrentSynchronizationContext());
}

更新:

没有额外加的点,IDBConnectInstance本身就是一个来自第三方库的接口。即进入库函数IDBConnectInstance.SelectRows,停止等待完成。如果可以处理CancellationToken,问题就不会出现了。

IDBConnect
{
    SelectRows();
}

public class DBConnect: IDBConnect
{
    public List<SomeClass> SelectRows()
    {
        String query = "Очень долгий SELECT из БД";
        List<SomeClass> result = new List<SomeClass>();
        using(OracleConnection dbconn = new OracleConnection(ConnectionString))
        {
            dbconn.Open();

            OracleCommand command = new OracleCommand(query, dbconn);
            OracleDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                SomeClass someClass = new someClass()
                {
                    SomeField = reader[0],
                    SomeField = reader[1],
                    ...
                }
                result.Add(someClass);
            }
            reader.Close();
            dbconn.Close();
        }
        return result;
    }
}

到目前为止,只有一个想法返回Thread并使用已弃用的Thread.Abort();

c#
  • 3 个回答
  • 10 Views
Martin Hope
Alex Krass
Asked: 2020-10-03 03:12:04 +0000 UTC

如何正确实施MVP模型?

  • 6

我试图弄清楚如何改进 WinForms 体验以及分离逻辑和表示。我遇到了一个带有简短示例的 MVP 模板,并试图弄清楚如何使用它。目前我有以下代码,但我认为我做错了什么。此外,多线程的实现根本不适合这个模型。因此问题是,如何在 WinForms 中正确实施 MVP 设计模式?

查看实现

interface ICustomer
{
    string FirstName { get; set; }
    string LastName { get; set; }
    string SurName { get; set; }
    string Address { get; set; }
    string Code { get; set; }

    event Action Search;
    event Action Cancel;
}

public partial class Customer : Form, ICustomer
{
    public string FirstName
    {
        get { return lblFirstName.Text; }
        set { lblFirstName.Text = value; }
    }

    public string LastName
    {
        get { return lblLastName.Text; }
        set { lblLastName.Text = value; }
    }

    public string SurName
    {
        get { return lblSurname.Text; }
        set { lblSurname.Text = value; }
    }

    public string Address
    {
        get { return lblAddress.Text; }
        set { lblAddress.Text = value; }
    }

    public string Code
    {
        get { return txtCode.Text; }
        set { txtCode.Text = value; }
    }

    public event Action Search;
    public event Action Cancel;

    public Customer()
    {
        InitializeComponent();
    }

    private void btnSearch_Click(object sender, EventArgs e)
    {
        Search();
    }

    private void btnCancel_Click(object sender, EventArgs e)
    {
        Cancel();
    }
}

演示器实现

class CustomerPresenter 
{
    public ICustomer View;
    public ICustomerModel Model;

    public CustomerPresenter(ICustomer view, ICustomerModel model)
    {
        View = view;
        Model = model;

        View.Search += View_Search;
        View.Cancel += View_Cancel;
    }

    private void View_Search()
    {
        new Task(() => {
            View.FirstName = "Alex Krass";
        }).Start();
    }

    private void View_Cancel()
    {

    }
}

模式与挑战

我的模型还是空的,按照我的理解,应该没有问题,通过Unity IoC调用所有这些耻辱。

class UnityIoC
{
    private static UnityContainer unityContainer;

    public static UnityContainer Instance 
    {
        get
        {
            if (unityContainer == null) CreateContainer();
            return unityContainer;
        }
    }

    private static void CreateContainer()
    {
        unityContainer = new UnityContainer();
        unityContainer.RegisterType<ICustomer, Customer>();
        unityContainer.RegisterType<ICustomerModel, CustomerModel>();
    }
} 

static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

    ApplicationContext context = new ApplicationContext()
    {
        MainForm = UnityIoC.Instance.Resolve<CustomerPresenter>().View as Form
    };
    context.MainForm.Show();

    Application.Run(context);
}

那么,相应地,当我单击“搜索”按钮时,我无法更新 UI,我真的必须将 TextBox 本身转发给 Presenter 中的 ICustomer 并调用 BeginInvoke 吗?或者我只是误解了 MVP 的实施?

更新:

在不阻塞的情况下更新 UI 的问题似乎已经通过使用计时器解决了,当信息需要在完成时Task和之后TaskScheduler,当它需要在完成后更新时Task。

**Вариант 1**

timer = new Timer() { Interval = 1000 };
timer.Tick += timer_Tick;
timer.Start();

private void timer_Tick(object sender, EventArgs e)
{
    UpdateView();
}

**Вариант 2**
task = new Task(new Action(UpdateModel));
task.ContinueWith(new Action<Task>(UpdateView), TaskScheduler.FromCurrentSynchronizationContext());
task.Start();


private void UpdateView(Task task = null)
{
    view.SomeVal = SomeVal;
    view.SomeValNext = SomeValNext;
}
c#
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5