我有一个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#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方法?
我正在尝试创建一个具有可变行数和列数的表.我有这样做ItemsControl具有Grid作为ItemsPanel.我知道我可以设置Grid.Row和Grid.Column每个项目通过的ItemContainerStyle.但是当我无法通过名称访问Grid时,我不知道如何更改行数和列数以及它们的大小.
你如何修改RowDefinitions或ColumnDefinitions的Grid使用只在运行时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.
我想知道是否有任何方法可以在运行时 …
我正在使用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个错误)
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\TeamFoundation\Instances%LocalAppData%\Microsoft\Team Foundation\4.0\Cache并删除一切经过一段漫长而绝望的时间尝试在线连接到TFS之后,现在我只想找到一种方法来检查我的更改.(手工操作不是一个选项,因为有大量的更改,我甚至不知道自上次登记后哪些文件被更改)
我有一个带有一个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) 我有一个ISomething定义的接口GetSomething().
我有一大堆的类Something1,Something2...都实现ISomething,因此GetSomething().
当我右键单击Something1.GetSomething()并单击时Find All References,VisualStudio将显示所有引用ISomething.GetSomething()而不是实际的派生类.
我想知道是否有办法导航到Something1.GetSomething()没有向下滚动所有的实现GetSomething()
我刚刚在VS Code上安装了python,但是我无法使用来运行任何python代码 python command。
好像用了 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
我正在尝试将 SSD 添加到启动菜单。我按照Microsoft提供的说明进行操作。但我不断收到同样的错误。
这个命令给了我错误:
bcdedit /copy {current} /d "mySSD"
Run Code Online (Sandbox Code Playgroud)
然后我跑去bcdedit /v看identifier'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) 我正在开发具有少数不同项目的 asp.net 核心解决方案,每个项目都使用某个版本库的 3rd 方 NuGet 包。这些版本,例如 1.0.0 和 2.0.0,有重大更改。另外,这个库是由另一个项目团队开发的,不受我的影响。所以在未来,将会有与另一个版本不兼容的版本,我的限制是在特定项目中使用一个确切的版本。
以下是该解决方案的最小概述:
在 Visual Studio 的开发过程中,一切都很好,我可以在每个项目中使用我的版本库的各个方法。如果我最终发布我的应用程序,输出文件夹中只有一个v2.0.0 的 CustomLibrary.dll。
我对此有点困惑。这个 dll 是否包含两个版本并且 dotnet 可以在运行时解析它们?如果不是这种情况,应用程序将在运行时失败,因为 v1.0.0 的方法和输出可能与 v2.0.0 完全不同。
(.NET Framework中我能做到这样,但似乎并不在.net中的核心应用)
是否有部署同一强命名库的不同版本的解决方案?我想应该可以部署特定版本的 NuGet 包吗?
如果您能帮助我,我将不胜感激。
我正在尝试在没有安装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# ×5
wpf ×3
.net-core ×1
asynchronous ×1
automation ×1
bcdedit ×1
boot ×1
build ×1
c#-8.0 ×1
com ×1
com-interop ×1
deployment ×1
grid ×1
ide ×1
interop ×1
itemscontrol ×1
nuget ×1
python ×1
refactoring ×1
templates ×1
tfs ×1
windows ×1
windows-10 ×1
wpfdatagrid ×1