我最近看到了一个公告和文章,概述了第一个Python 3.0候选版本的发布.我想知道是否有任何支持其语法的商业,免费,开源等IDE.
好吧,这可能非常简单但是,我有以下"检查",(not at the same time)并且第一个 ALWAYS评估为TRUE,而第二个 SEEMS工作.这实际上发生在行值为数字或布尔值的每个地方(Date seems fine...).
如果我走通过代码调试它显示的数值row["PersonID"]为162434,一样tbxPersonID.EditValue.这只是我错过的编程的基本和初学真理hodge-podge-self-education吗?
看来,如果我把所有问题都string写成第一个,我会很好,我只想知道我是否正确,是否有一般规则Types我需要做什么呢?
if (row["PersonID"] != tbxPersonID.EditValue)
{
row["PersonID"] = tbxPersonID.EditValue;
}
if (row["CitizenFlag"] != chkCitizen.EditValue)
{
row["CitizenFlag"] = chkCitizen.EditValue;
_whatChanged.Add("CitizenFlag");
}
Run Code Online (Sandbox Code Playgroud)
if (row["PersonID"].ToString() != tbxPersonID.EditValue.ToString())
{
row["PersonID"] = tbxPersonID.EditValue;
}
if (row["CitizenFlag"].ToString() != chkCitizen.EditValue.ToString())
{
row["CitizenFlag"] = chkCitizen.EditValue;
_whatChanged.Add("CitizenFlag");
}
Run Code Online (Sandbox Code Playgroud) 我正在研究用于读取FAT32引导扇区和BPB的C#项目,问题是我正在使用编组机制将字节数组转换为自定义FAT32数据结构.我收到一条消息错误说:无法从程序集"FAT32Management,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null"加载类型"FAT32Management.Fat32BootSector",因为它包含偏移量为3的对象字段未正确对齐或重叠由非对象字段.
我无法解决问题
这是代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace FAT32Management
{
[StructLayout(LayoutKind.Explicit)]//, CharSet = CharSet.Ansi, Size = 96, Pack = 1)]
public struct Fat32BootSector
{
#region Common Region With all FAT systems
/// <summary>
/// First 3 Bytes of the Jump insctructions.
/// Offset 0x00
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
[FieldOffset(0x00)]
public byte[] JumpBootInstructions;
/// <summary>
/// 8 Bytes of the OemName
/// Offset 0x03
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, …Run Code Online (Sandbox Code Playgroud) 我在.Net中遇到了一些关于垃圾收集的奇怪行为.
以下程序将非常快速地抛出OutOfMemoryException(在32位,2GB机器上不到一秒钟之后).永远不会调用Foo终结器.
class Foo
{
Guid guid = Guid.NewGuid();
byte[] buffer = new byte[1000000];
static Random rand = new Random();
public Foo()
{
// Uncomment the following line and the program will run forever.
// rand.NextBytes(buffer);
}
~Foo()
{
// This finalizer is never called unless the rand.NextBytes
// line in the constructor is uncommented.
}
static public void Main(string args[])
{
for (; ; )
{
new Foo();
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果取消注释rand.nextBytes行,它将无限运行,并定期调用Foo终结器.这是为什么?
我最好的猜测是,在前一种情况下,CLR或Windows VMM都懒得分配物理内存.永远不会写入缓冲区,因此永远不会使用物理内存.当地址空间用完时,系统崩溃.在后一种情况下,系统在用完地址空间之前耗尽物理内存,触发GC并收集对象.
但是,这是我没有得到的部分.假设我的理论是正确的,为什么地址空间不足时GC不会触发?如果我的理论不正确,那么真正的解释是什么呢?
我正在研究一个需要高文件I/O性能的系统(使用C#).基本上,我从文件的开头填充大文件(~100MB)直到文件结束.每隔约5秒我就会向文件中添加〜5MB(从文件的开头顺序),每次批量我都在刷新流.每隔几分钟我就需要更新一个我在文件末尾写的结构(某种元数据).
当冲洗每个散装时,我没有性能问题.但是,当更新文件末尾的元数据时,我的性能确实很低.我的猜测是,在创建文件时(也应该加快速度),文件并不真正在磁盘上分配整个100MB,当我刷新元数据时,它必须分配所有空间直到文件结束.
男孩/女孩,任何想法我怎么能克服这个问题?
非常感谢!
来自评论:
一般来说,代码如下,首先打开文件:
m_Stream = new FileStream(filename,
FileMode.CreateNew,
FileAccess.Write,
FileShare.Write, 8192, false);
m_Stream.SetLength(100*1024*1024);
Run Code Online (Sandbox Code Playgroud)
每隔几秒我就会写5MB.
m_Stream.Seek(m_LastPosition, SeekOrigin.Begin);
m_Stream.Write(buffer, 0, buffer.Length);
m_Stream.Flush();
m_LastPosition += buffer.Length; // HH: guessed the +=
m_Stream.Seek(m_MetaDataSize, SeekOrigin.End);
m_Stream.Write(metadata, 0, metadata.Length);
m_Stream.Flush(); // Takes too long on the first time(~1 sec).
Run Code Online (Sandbox Code Playgroud) <?xml version="1.0" encoding="utf-8"?>
<rsp stat="ok">
<image_hash>cxmHM</image_hash>
<delete_hash>NNy6VNpiAA</delete_hash>
<original_image>http://imgur.com/cxmHM.png</original_image>
<large_thumbnail>http://imgur.com/cxmHMl.png</large_thumbnail>
<small_thumbnail>http://imgur.com/cxmHMl.png</small_thumbnail>
<imgur_page>http://imgur.com/cxmHM</imgur_page>
<delete_page>http://imgur.com/delete/NNy6VNpiAA</delete_page>
</rsp>
Run Code Online (Sandbox Code Playgroud)
这是我将收到的典型回复.我尝试了以下但是我收到一个错误,告诉我非空白字符不能添加到内容.
XDocument response = new XDocument(w.UploadValues("http://imgur.com/api/upload.xml", values));
Run Code Online (Sandbox Code Playgroud) 我在C#中开发了一个窗口应用程序,我正在创建一个线程来执行一个调度事件.现在这个应用程序将运行一整天,它将为每个事件的每次执行创建一个线程.如何在分配给该线程的任务完成后从内存中删除线程.我不想通过使用线程池限制线程创建数量并为其分配最大线程的特定计数.
我正在尝试数据绑定 DataGridComboBoxColumn
<DataGridComboBoxColumn Header="Number of Copies" SelectedItemBinding="{Binding NumberCopies}">
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding LifeAreaList}"/>
<Setter Property="IsReadOnly" Value="True"/>
</Style>
</DataGridComboBoxColumn.ElementStyle>
</DataGridComboBoxColumn>
Run Code Online (Sandbox Code Playgroud)
我在这里做错了,因为我在运行时得到一个空的组合框.
我得到了关注
System.Windows.Data错误:2:找不到目标元素的管理FrameworkElement或FrameworkContentElement.BindingExpression:路径= LifeAreaList; 的DataItem = NULL; target元素是'DataGridComboBoxColumn'(HashCode = 49475561); target属性是'ItemsSource'(输入'IEnumerable')
有关于每个枚举的定义的文档.但是我怎么能在实践中演示/看到这个?我怎么可能知道何时使用哪个优先级?
下面是一些代码,我已经在尝试看到先决如何影响排序创建的,它为我提供了证据,证明的顺序是正确的(第一循环迭代将增加一个SystemIdle枚举到调度队列),但它仍然有加最后一个字符串
private void btn_Click(object sender, RoutedEventArgs e)
{
StringBuilder result = new StringBuilder();
new Thread(() =>
{
var vals = Enum.GetValues(typeof(DispatcherPriority)).Cast<DispatcherPriority>().Where(y => y >= 0).ToList();
vals.Reverse();
vals.ForEach(x =>
{
Dispatcher.BeginInvoke(new Action(() =>
{
result.AppendLine(string.Format("Priority: {0} Enum:{1}", ((int)x), x.ToString()));
}), x);
});
}).Start();
ShowResultAsync(result, 2000);
}
private async void ShowResultAsync(StringBuilder s, int delay)
{
await Task.Delay(delay);
MessageBox.Show(s.ToString());
}
Run Code Online (Sandbox Code Playgroud)
并且输出顺序保持不变,即使列表反转(在vals分配后添加此行):
vals.Reverse();
Run Code Online (Sandbox Code Playgroud)
那么,在确定我应该分配哪个调度优先级时,还有什么我可以使用的吗?
c# ×7
.net ×4
wpf ×2
binding ×1
clr ×1
datagrid ×1
dispatcher ×1
file-io ×1
ide ×1
linq-to-xml ×1
marshalling ×1
performance ×1
python ×1
python-3.x ×1
syntax ×1
typechecking ×1
types ×1
unmanaged ×1
webclient ×1
winforms ×1
xaml ×1