Visual Studio 2017社区版
我试图了解/使用Performance Profiler的内存使用情况,我认为应用程序中的内存泄漏(带有自定义控件的MVVM).拍摄了三个快照:
然后我将快照#3与快照#1进行了比较.在结果表中,我强加了一个"NewProgressNoteView"的过滤器.以下是扩展顶级Doctor_Desk.Views.NewProgressNoteView实例的结果.值得注意的是'[检测到周期]感觉可疑,但我不知道它究竟意味着什么,或者如何使用这些信息来修复内存泄漏?接下来我该怎么办?
非常感激任何的帮助.
TIA.
我一直无法找到一个干净,简单的示例,说明如何使用在MVVM框架中具有依赖项属性的WPF 正确实现usercontrol.每当我为usercontrol分配一个datacontext时,我的代码都会失败.
我在尝试着:
我还有很多东西需要学习,并真诚地感谢任何帮助.
这是最顶层的usercontrol中的ItemsControl,它使用依赖项属性TextInControl调用InkStringView用户控件(来自另一个问题的示例).
<ItemsControl
ItemsSource="{Binding Strings}" x:Name="self" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataTemplate.Resources>
<Style TargetType="v:InkStringView">
<Setter Property="FontSize" Value="25"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
</DataTemplate.Resources>
<v:InkStringView TextInControl="{Binding text, ElementName=self}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
这是带有依赖项属性的InkStringView用户控件.
XAML:
<UserControl x:Class="Nova5.UI.Views.Ink.InkStringView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
x:Name="mainInkStringView"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding TextInControl, ElementName=mainInkStringView}" />
<TextBlock Grid.Row="1" Text="I am row 1" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
Code-Behind file:
namespace Nova5.UI.Views.Ink
{
public …Run Code Online (Sandbox Code Playgroud) 有些情况下,由于大量的INotifyChangedProperties事件,您有许多UI更新.在这种情况下,您可能只想在批量设置所有属性时仅向UI发出一次更改信号.
我发现这篇很棒的文章解释了如何推迟ViewCollection的刷新:
http://marlongrech.wordpress.com/2008/11/22/icollectionview-explained/
但是当View被推迟时我得到一个例外,我尝试在集合中添加一些东西.我不明白为什么不允许这样做.这就是它的第一点.
InvalidoperationException: 在延迟刷新时无法更改或检查CollectionView的内容或当前位置.
有谁知道如何解决这个问题?非常感谢,
我完全迷失了.在Visual Studio 2015中,我创建了一个WCF库服务项目并定义了服务和服务接口.
使用NuGet控制台安装了EntityFramework,EntityFramework.SqlServer,EntityFramework6.Npgsql和Npgsql:
将库服务设置为启动然后启动调试(f5)正确读取可用的过程.但是,在测试WcfSvcHost中的任何过程时,我收到以下错误:
具有不变名称"Npgsql"的ADO.NET提供程序未在计算机或应用程序配置文件中注册,或者无法加载.有关详细信息,请参阅内部异常
我做错了什么?
这是App.config文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's …Run Code Online (Sandbox Code Playgroud) 这与我的其他问题如何取消后台打印有关.
我试图更好地理解CancellationTokenSource模型以及如何跨线程边界使用它.
我有一个主窗口(在UI线程上)后面的代码:
public MainWindow()
{
InitializeComponent();
Loaded += (s, e) => {
DataContext = new MainWindowViewModel();
Closing += ((MainWindowViewModel)DataContext).MainWindow_Closing;
};
}
Run Code Online (Sandbox Code Playgroud)
它在关闭时正确调用CloseWindow代码:
private void CloseWindow(IClosable window)
{
if (window != null)
{
windowClosingCTS.Cancel();
window.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
通过选择菜单项,在后台线程上创建第二个窗口:
// Print Preview
public static void PrintPreview(FixedDocument fixeddocument, CancellationToken ct)
{
// Was cancellation already requested?
if (ct.IsCancellationRequested)
ct.ThrowIfCancellationRequested();
...............................
// Use my custom document viewer (the print button is removed).
var previewWindow = new PrintPreview(fixedDocumentSequence);
//Register the cancellation procedure …Run Code Online (Sandbox Code Playgroud) 尝试学习使用Regex(正则表达式)的更多信息.在C#(VS 2010)中使用微软的Regex版本,我怎么能得到一个简单的字符串:
"Hello"
Run Code Online (Sandbox Code Playgroud)
并将其更改为
"H e l l o"
Run Code Online (Sandbox Code Playgroud)
这可以是任何字母或符号,大写字母,小写字母等的字符串,并且没有其他字母或符号跟随或引导该单词.(该字符串仅包含一个单词).
(我已经阅读了其他帖子,但我似乎无法掌握正则表达式.请善待:)).
感谢您的帮助.(解释最有用).
我想在父抽象类中声明以下内容:
public abstract void RefreshDisplay<TView>(Enum value);
Run Code Online (Sandbox Code Playgroud)
然后将在子类中实现,如:
public override void RefreshDisplay<RxViewModel>(RxViews view)
Run Code Online (Sandbox Code Playgroud)
其中RxViews是枚举,并从该枚举"查看"特定值.
直到运行时才会知道它来自的实际视图和枚举.
可以这样做吗?我很感激帮助.
编辑:我可能会问这个错误.TView不是枚举,而是从ViewModelBase继承的视图.(我不知道这是一个重复的问题?)谢谢.
编辑:我猜这是在4.5中修复的.任何想法如何在net 4.0中解决这个问题?
我希望创建一个存储过程(在plpgsql,PostgreSQL 9.1中),首先检查以确保要插入的记录在其四个列上是唯一的,或者如果更新了记录,则将其更新为唯一值.
Example:
Record (1,2,3,4) is to be inserted.
If Record (1,2,3,4) already exists, then do not insert a duplicate record.
if Record (1,2,3,4) does not exist, then insert it.
Record (1,2,3,4) is to be updated to (5,6,7,8).
If Record (5,6,7,8) already exists, then do not update the record. (duplicate record not allowed).
If Record (5,6,7,8) does not exist, then update the record to the new values.
Run Code Online (Sandbox Code Playgroud)
我之前在记录的字段上使用过唯一索引,但是想了解如何编写触发器来完成此操作.
我确信这是常见的地方,但谷歌没有帮助.我试图在PostgreSQL 9.1中编写一个简单的存储过程,它将从父cpt表中删除重复的条目.父表cpt由子表引用,lab定义为:
CREATE TABLE lab (
recid serial NOT NULL,
cpt_recid integer,
........
CONSTRAINT cs_cpt FOREIGN KEY (cpt_recid)
REFERENCES cpt (recid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE RESTRICT,
...
);
Run Code Online (Sandbox Code Playgroud)
我遇到的最大问题是如何获取失败的记录,以便我可以在EXCEPTION子句中使用它将子行移动lab到一个可接受的键,然后循环返回并从cpt表中删除不必要的记录.
这是(非常错误的)代码:
CREATE OR REPLACE FUNCTION h_RemoveDuplicateCPT()
RETURNS void AS
$BODY$
BEGIN
LOOP
BEGIN
DELETE FROM cpt
WHERE recid IN (
SELECT recid
FROM (
SELECT recid,
row_number() over (partition BY cdesc ORDER BY recid) AS …Run Code Online (Sandbox Code Playgroud) 如何在 Google ProtoBuf 中表示空时间戳?
我正在从 postgreSQL 数据库中读取日期时间(其中一些为空)到 protobuf 时间戳中。
message test {
google.protobuf.TimestampValue TransactionTime =1;
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,没有像 google.protobuf.TimestampValue 这样的动物。
非常感谢任何帮助。
TIA
c# ×4
plpgsql ×2
postgresql ×2
wpf ×2
constraints ×1
data-binding ×1
database ×1
deferred ×1
exception ×1
foreign-keys ×1
generics ×1
grpc ×1
memory-leaks ×1
mvvm ×1
npgsql ×1
regex ×1
timestamp ×1
triggers ×1
wcf ×1