小编Biz*_*han的帖子

如何从WPF gui运行异步任务并与之交互

我有一个WPF GUI,我想按下一个按钮来启动一个长任务,而不会在任务期间冻结窗口.当任务正在运行时,我想获得有关进度的报告,我想在我选择的任何时候添加另一个按钮来停止任务.

我无法想出使用async/await/task的正确方法.我不能包括我尝试的所有东西,但这就是我现在拥有的东西.

一个WPF窗口类:

public partial class MainWindow : Window
{
    readonly otherClass _burnBabyBurn = new OtherClass();
    internal bool StopWorking = false;

    //A button method to start the long running method
    private async void Button_Click_3(object sender, RoutedEventArgs e)
    {   
        Task burnTheBaby = _burnBabyBurn.ExecuteLongProcedureAsync(this, intParam1, intParam2, intParam3);

        await burnTheBaby;
    }

    //A button Method to interrupt and stop the long running method
    private void StopButton_Click(object sender, RoutedEventArgs e)
    {
        StopWorking = true;
    }

    //A method to allow the worker method to call …
Run Code Online (Sandbox Code Playgroud)

c# wpf asynchronous

44
推荐指数
4
解决办法
5万
查看次数

IDE0063什么时候配置?

我试图了解此C#8简化功能:

IDE0063的“使用”语句可以简化

例如,我有:

void Method()
{
    using (var client = new Client())
    {
        // pre code...
        client.Do();
        // post code...
    } --> client.Dispose() was called here.
    // more code...
}
Run Code Online (Sandbox Code Playgroud)

IDE告诉我可以using通过编写以下代码来简化此语句:

void Method()
{
    using (var client = new Client());
    // pre code...
    client.Do();
    // post code...
    // more code...
}
Run Code Online (Sandbox Code Playgroud)

我不明白它是如何工作的以及它如何决定我不再using是变量。更具体地说,它什么时候调用client.Dispose方法?

c# ide refactoring c#-8.0

14
推荐指数
2
解决办法
1717
查看次数

如何使用绑定动态地将RowDefinition或ColumnDefinition添加到Grid?

我正在尝试创建一个具有可变行数和列数的表.我有这样做ItemsControl具有Grid作为ItemsPanel.我知道我可以设置Grid.RowGrid.Column每个项目通过的ItemContainerStyle.但是当我无法通过名称访问Grid时,我不知道如何更改行数和列数以及它们的大小.


题:

你如何修改RowDefinitionsColumnDefinitionsGrid使用只在运行时XAML结合无代码隐藏


这是XAML代码:

<ItemsControl Name="myItemsControl" ItemsSource="{Binding Cells}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Grid Name="myGrid">

                <Grid.RowDefinitions>
                    <!-- unknown number of rows are added here in run-time -->
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <!-- known number of columns are added here in run-time -->
                </Grid.ColumnDefinitions>

            </Grid>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemContainerStyle>
        <Style.../>
    </ItemsControl.ItemContainerStyle>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)

我试图添加一些RowDefinition代码,但我找不到myGrid通过其名称(或任何其他方式)访问的方法,因为它在一个内部ItemsPanelTemplate.

我想知道是否有任何方法可以在运行时 …

wpf grid templates itemscontrol

12
推荐指数
2
解决办法
3万
查看次数

TF31002无法从VS 2012在线连接到TFS

问题

我正在使用VisualStudio 2012 Ultimate v11.0.50727.1 Update 4,VisualStudio 2013 Ultimate v12.0.21005 EL而且我可以通过任何浏览器连接到TFS.但突然间我无法再从VisualStudio内的xxxxx .VisualStudio.com连接到TFS .昨天我很容易在同一个账户上办理登机手续.但是我无法在家里连接到TFS.

这是我正在使用的URL :(我尝试更改它有点像添加/ tfs或/ DefaultCollection)

在此输入图像描述

我坚持这个,我尝试了不同的方法,但到目前为止还没有工作,它仍然给我这些错误:TF31002,TF300324和TF205020

在此输入图像描述

TF31002(尝试添加新服务器时发生此错误)

TF205020:无法连接到服务器' https://xxxxxx.visualstudio.com/defaultcollection '.此服务器在上次会话中使用,但可能处于脱机或无法访问状态.确认服务器在网络上可用.要尝试再次连接或连接到其他服务器,请单击"团队资源管理器"或"团队"菜单中的"连接到Team Foundation Server".

TF400324:服务器https://xxxxxx.visualstudio.com/defaultcollection中不提供Team Foundation服务.技术信息(对于管理员):基础连接已关闭:发送时发生意外错误.

(当VisualStudio尝试登录到tfs时发生最后2个错误)

我试过这些:

  1. 转到VisualStudio.com并从所有浏览器注销
  2. 删除IE10的Cookie和缓存(并在IE登录visualstudio.com或签名时进行测试)
  3. 转到Regedit并将DWORD设置为0 in HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\TeamFoundation\Instances
  4. 浏览%LocalAppData%\Microsoft\Team Foundation\4.0\Cache并删除一切
  5. 从Windows凭据管理器中删除所有凭据(并删除链接在线ID)
  6. 安装VS2013
  7. 安装了Team Explorer 2013
  8. 已安装VS2012 Update 4
  9. 安装了Windows 8的全新副本

我想要的是.

经过一段漫长而绝望的时间尝试在线连接到TFS之后,现在我只想找到一种方法来检查我的更改.(手工操作不是一个选项,因为有大量的更改,我甚至不知道自上次登记后哪些文件被更改)

tfs visual-studio visual-studio-2012 visual-studio-2013

11
推荐指数
2
解决办法
3万
查看次数

如何在WPF DataGrid中通过DataGrid标头CheckBox选择列的所有复选框

我有一个带有一个CheckBoxColumn的DataGrid.在CheckBoxColumn的标题中,我添加了一个CheckBox来选择该Datagrid Row的所有CheckBox.

我怎样才能做到这一点?

我的WPF dataGrid的XAML代码:

    <DataGrid AutoGenerateColumns="False" CanUserAddRows="False"  Grid.RowSpan="2" Height="130" HorizontalAlignment="Left" IsReadOnly="False" Margin="189,340,0,0" Name="dgCandidate" TabIndex="7" VerticalAlignment="Top" Width="466" Grid.Row="1" >
        <DataGrid.Columns>
            <DataGridTextColumn x:Name="colCandidateID" Binding="{Binding CandidateID}" Header="SlNo" MinWidth="20" IsReadOnly="True" />
            <DataGridTextColumn x:Name="colRegistraion" Binding="{Binding RegisterNo}" Header="Reg. No." IsReadOnly="True"  />
            <DataGridTextColumn x:Name="colCandidate" Binding="{Binding CandidateName}" Header="Name" MinWidth="250" IsReadOnly="True"  />

            <DataGridTemplateColumn>
                <DataGridTemplateColumn.Header>
                    <CheckBox Name="chkSelectAll" Checked="chkSelectAll_Checked" Unchecked="chkSelectAll_Unchecked"></CheckBox>
                </DataGridTemplateColumn.Header>
                <DataGridTemplateColumn.CellTemplate >
                    <DataTemplate >
                        <CheckBox x:Name="colchkSelect1" Checked="colchkSelect1_Checked" Unchecked="colchkSelect1_Unchecked" ></CheckBox>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

        </DataGrid.Columns>

    </DataGrid>
Run Code Online (Sandbox Code Playgroud)

c# wpf wpfdatagrid

8
推荐指数
1
解决办法
2万
查看次数

查找VisualStudio中覆盖方法的所有引用

我有一个ISomething定义的接口GetSomething().

我有一大堆的类Something1,Something2...都实现ISomething,因此GetSomething().

当我右键单击Something1.GetSomething()并单击时Find All References,VisualStudio将显示所有引用ISomething.GetSomething()而不是实际的派生类.

我想知道是否有办法导航到Something1.GetSomething()没有向下滚动所有的实现GetSomething()

visual-studio-2012 visual-studio-2013

6
推荐指数
1
解决办法
786
查看次数

VSCode:术语“ python”无法识别...但是py可以工作

我刚刚在VS Code上安装了python,但是我无法使用来运行任何python代码 python command。

python命令:

好像用了 python默认情况下命令,但无法识别命令。

当我右键单击并选择Run Code它时抱怨:

'python' is not recognized as an internal or external command, operable program or batch file

手动运行也是如此 python main.py

当我打开提升的PowerShell并运行时python,它抱怨:

python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python …
Run Code Online (Sandbox Code Playgroud)

python automation build visual-studio-code vscode-code-runner

6
推荐指数
2
解决办法
1万
查看次数

BCDEdit错误,参数不正确

我正在尝试将 SSD 添加到启动菜单。我按照Microsoft提供的说明进行操作。但我不断收到同样的错误。

这个命令给了我错误:

bcdedit /copy {current} /d "mySSD"
Run Code Online (Sandbox Code Playgroud)

然后我跑去bcdedit /videntifier'sGUID。这个命令也给了我同样的错误:

bcdedit /copy {c562ef5b-d0f6-11e8-bfb5-e86a64139893} /d "mySSD"
Run Code Online (Sandbox Code Playgroud)

错误:

The copy command specified is not valid.
Run "bcdedit /?" for command line assistance.
The parameter is incorrect.
Run Code Online (Sandbox Code Playgroud)

我应该怎么办?


这是输出结果bcdedit /v

Windows Boot Manager
--------------------
identifier              {9dea862c-5cdd-4e70-accb-f32b344d4795}
device                  partition=\Device\HarddiskVolume1
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  en-US
inherit                 {7ea2e1ac-2e61-4728-aaab-896d9d0a9f0e}
default                 {c562ef5b-d0f6-11e8-bfb5-e86a64139893}
resumeobject            {c562ef5a-d0f6-11e8-bfb5-e86a64139893}
displayorder            {c562ef5b-d0f6-11e8-bfb5-e86a64139893}
toolsdisplayorder       {b2721d73-1db4-4c62-bf7b-c548a880142d}
timeout                 0

Windows Boot Loader
-------------------
identifier              {c562ef5b-d0f6-11e8-bfb5-e86a64139893} …
Run Code Online (Sandbox Code Playgroud)

windows boot bcdedit windows-10

6
推荐指数
1
解决办法
7516
查看次数

如何解决dotnet核心中的nuget依赖地狱?

我正在开发具有少数不同项目的 asp.net 核心解决方案,每个项目都使用某个版本库的 3rd 方 NuGet 包。这些版本,例如 1.0.0 和 2.0.0,有重大更改。另外,这个库是由另一个项目团队开发的,不受我的影响。所以在未来,将会有与另一个版本不兼容的版本,我的限制是在特定项目中使用一个确切的版本。

以下是该解决方案的最小概述:

  • 我的解决方案
    • 网络应用程序
    • 项目1
      • 自定义库 (v1.0.0)
    • 项目2
      • 自定义库 (v2.0.0)

在 Visual Studio 的开发过程中,一切都很好,我可以在每个项目中使用我的版本库的各个方法。如果我最终发布我的应用程序,输出文件夹中只有一个v2.0.0 的 CustomLibrary.dll

我对此有点困惑。这个 dll 是否包含两个版本并且 dotnet 可以在运行时解析它们?如果不是这种情况,应用程序将在运行时失败,因为 v1.0.0 的方法和输出可能与 v2.0.0 完全不同。

(.NET Framework中我能做到这样,但似乎并不在.net中的核心应用)

是否有部署同一强命名库的不同版本的解决方案?我想应该可以部署特定版本的 NuGet 包吗?

如果您能帮助我,我将不胜感激。

c# deployment nuget .net-core

6
推荐指数
1
解决办法
1363
查看次数

COM异常80040154创建Excel应用程序时

我正在尝试在没有安装Office的服务器上运行我的应用程序.

using EXCEL = Microsoft.Office.Interop.Excel;
...
EXCEL.Application app = new EXCEL.Application();//Exception thrown here
Run Code Online (Sandbox Code Playgroud)

代码在我自己的系统上工作正常,但在服务器上它提供以下异常:

Unhandled Exception: System.Runtime.InteropServices.COMException: 
Retrieving the COM class factory for component with CLSID {...} failed
due to the following error: 80040154 Class not registered
(Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Run Code Online (Sandbox Code Playgroud)

两个系统都是32位,我在应用程序的exe旁边复制了excel Interop dll.我也安装了O2010PIA.

任何铅?

c# com interop com-interop office-interop

5
推荐指数
1
解决办法
1万
查看次数