应用程序
我正在构建一个包含范围选择器的应用程序.这包含Slider一个UserControl派生类中包含的两个自定义绘制控件.然后,范围选择器控件包含在ScrollViewer大多数时间都可见的HorizonalScrollBar中.
示例应用程序代码:(文本墙的应用)
Window.xaml(Window文件):
<Grid>
<ScrollViewer x:Name="ScrollViewer" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled">
<local:SliderTest x:Name="slider"
LowerValue="0"
UpperValue="10"
Minimum="0"
Maximum="100" Width="900" Height="165" Padding="15,0,15,0" HorizontalAlignment="Left">
</local:SliderTest>
</ScrollViewer>
</Grid>
Run Code Online (Sandbox Code Playgroud)
SliderTest.xaml:
<UserControl x:Class="scrollviewerDemoProblem.SliderTest"
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="root"
xmlns:local="clr-namespace:scrollviewerDemoProblem"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<ControlTemplate x:Key="simpleSlider" TargetType="{x:Type Slider}">
<Border SnapsToDevicePixels="true" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Track x:Name="PART_Track" Grid.Row="1">
<Track.Thumb>
<Thumb x:Name="Thumb" FlowDirection="LeftToRight" Width="15">
<Thumb.Template>
<ControlTemplate TargetType="Thumb">
<Canvas>
<Path x:Name="test1" StrokeThickness="0" …Run Code Online (Sandbox Code Playgroud) 我有一个网站应用程序在IIS 7.0上运行它自己的应用程序池.该应用程序是一个ASP.NET MVC 3网站.
我注意到这个应用程序的内存使用情况对应w3wp IIS工作服务是相当高的(800 MB,有一些波动).
我正在尝试诊断问题,并尝试了以下方法:
我已在IIS级别禁用网站的输出页面缓存,然后回收应用程序池.这会导致w3wp进程重新启动.然后,此过程的内存使用量会慢慢增加到大约800 MB,这需要大约30秒才能完成.目前没有处理页面请求.当我从IIS重新启动网站时,进程的内存大小不会改变.
我尝试从VS 2010运行应用程序的调试副本,内存使用没有问题.
我有一些想法/问题是:
这个问题与网站代码有关吗? - 鉴于在发送/处理任何页面请求之前内存火箭,我会认为这不是代码问题?
在MVC中构建的应用程序没有处理写入其中的缓存.
该网站使用实时数据显示,它定期使用ajax请求,并且通常长时间保持"开放"状态.
在应用程序被回收并且没有发送用户请求之后,为什么内存使用量会增加?这是因为它将旧的缓存信息从磁盘加载到它的内存中吗?
应用程序不会崩溃,我只关心内存使用情况,它不是一个网站的大...
任何想法/帮助解决这个问题的底部将不胜感激.
我在C#中有一个Windows窗体应用程序,它监视鼠标按钮是否被按下.GUI有一个主线程,它产生一个辅助STA线程.此代码永远不会在其中执行:
if (Mouse.LeftButton == MouseButtonState.Pressed)
{
System.Diagnostics.Debug.WriteLine("Left mouse down");
}
Run Code Online (Sandbox Code Playgroud)
我想知道这是否是因为我为该线程启用了以下STA选项?
repeaterThread.SetApartmentState(ApartmentState.STA);
repeaterThread.Start();
Run Code Online (Sandbox Code Playgroud)
完整的相关代码:我正在使用PresentationCore.dll,和System.Windows.Input; Winforms GUI:
按下开始按钮:
...
Thread repeaterThread = new Thread(() => ListenerThread());
repeaterThread.SetApartmentState(ApartmentState.STA);
repeaterThread.Start();
...
Run Code Online (Sandbox Code Playgroud)
ListenerThread方法:
public static void ListenerThread()
{
while(true)
{
if (Mouse.LeftButton == MouseButtonState.Pressed)
{
System.Diagnostics.Debug.WriteLine("Left mouse down");
}
Thread.sleep(1000);
}
}
Run Code Online (Sandbox Code Playgroud)
如果从该线程中按下鼠标按钮,我该如何捕获?
谢谢
I have a byte array which I believe correctly stores a UTF-16 encoded Surrogate Pair for the unicode character
Running that byte array through .Net System.Text.Encoding.Unicode.GetString() returns non-expected results.
Actual results: ??
Expected results:
Code example:
byte[] inputByteArray = new byte[4];
inputByteArray[0] = 0x91;
inputByteArray[1] = 0xDF;
inputByteArray[2] = 0x00;
inputByteArray[3] = 0xD8;
// System.Text.Encoding.Unicode accepts little endian UTF-16
// Least significant byte first within the byte array [0] MSByete in [3]
string str = System.Text.Encoding.Unicode.GetString(inputByteArray);
// This returns ?? …Run Code Online (Sandbox Code Playgroud) 我有一个拥有3000万行的数据库.PK聚集索引是生成的代码GUID.
表格如下:
CREATE TABLE [dbo].[events](
[imageEventGUID] [uniqueidentifier] NOT NULL,
[imageSHAID] [nvarchar](256) NOT NULL,
[queryGUID] [uniqueidentifier] NOT NULL,
[eventType] [int] NOT NULL,
[eventValue] [nvarchar](2050) NULL,
[dateOfEvent] [datetime] NOT NULL,
CONSTRAINT [PK_store_image_event] PRIMARY KEY CLUSTERED
(
[imageEventGUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
Run Code Online (Sandbox Code Playgroud)
简单地说它是一个图像搜索引擎.
imageEventGUID 是代码唯一标识符, imageSHAID 是图像URL的SHA256queryGUID 是生成FK的代码(为简洁起见,从create语句中排除)eventType 是一个分配给它是什么类型的事件的数字eventValue通常是图像的URI,例如" http://mywebpage.com/images/image123456789.jpg "我定期使用非常标准的代码将via SqlBulkCopy(从a DataTable)插入到此表中:
using (SqlBulkCopy …Run Code Online (Sandbox Code Playgroud) 我有一个包含 500 万行的数据库表。聚集索引是自增标识列。PK 是生成 256 字节的代码VARCHAR,它是 URL 的 SHA256 哈希,这是表上的非聚集索引。
表格如下:
CREATE TABLE [dbo].[store_image](
[imageSHAID] [nvarchar](256) NOT NULL,
[imageGUID] [uniqueidentifier] NOT NULL,
[imageURL] [nvarchar](2000) NOT NULL,
[showCount] [bigint] NOT NULL,
[imageURLIndex] AS (CONVERT([nvarchar](450),[imageURL],(0))),
[autoIncID] [bigint] IDENTITY(1,1) NOT NULL,
CONSTRAINT [PK_imageSHAID] PRIMARY KEY NONCLUSTERED
(
[imageSHAID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [autoIncPK] ON [dbo].[store_image]
(
[autoIncID] ASC
)WITH …Run Code Online (Sandbox Code Playgroud) 样品申请:
提供的代码所属的示例应用程序Vehicle通过Binding 显示对象列表.本Vehicle类是顶层类子类可以从如派生Car和Bike.此时的示例应用程序显示所有者的名称Vehicle.
示例型号代码:
public class Vehicle
{
private string _ownerName;
public string ownerName
{
get { return _ownerName; }
set { _ownerName = value; }
}
}
public class Car : Vehicle
{
public int doors;
}
public class Bike : Vehicle
{
// <insert variables unique to a bike, ( I could not think of any...)>
}
Run Code Online (Sandbox Code Playgroud)
UserControl XAML代码:
<Grid>
<Grid.Resources>
<DataTemplate x:Key="itemTemplate">
<WrapPanel>
<TextBlock Text="{Binding Path=ownerName}"/>
</WrapPanel> …Run Code Online (Sandbox Code Playgroud)