C#, Event Handlers and Threading

I'm writing a little chat app, and I have this event handler: void o_Typing(object sender, EventArgs e) { MessageBox.Show("Fired!"); this.Text = "Fired!"; } o_Typing is a method in a class derived from TabPage . Basically, I want each conversation to have it's own tab. The event handlers are fired by my Chat object, which is running in another thread. I have 1 thread for UI,

C#,事件处理程序和线程

我正在写一个小聊天应用程序,并且我有这个事件处理程序: void o_Typing(object sender, EventArgs e) { MessageBox.Show("Fired!"); this.Text = "Fired!"; } o_Typing是从TabPage派生的类中的一种方法。 基本上,我希望每个对话都有自己的选项卡。 事件处理程序由我的Chat对象触发,该对象正在另一个线程中运行。 我有一个用于UI的线程,另一个线程用于每个聊天对话(为了保持轮询服务器的新数据) 当事件被

Order of event handler execution

If I set up multiple event handlers, like so: _webservice.RetrieveDataCompleted += ProcessData1; _webservice.RetrieveDataCompleted += ProcessData2; what order are the handlers run when the event RetrieveDataCompleted is fired? Are they run in the same thread and sequentially in the order that are registered? Currently, they are executed in the order they are registered. However, this is an

事件处理程序执行顺序

如果我设置了多个事件处理程序,如下所示: _webservice.RetrieveDataCompleted += ProcessData1; _webservice.RetrieveDataCompleted += ProcessData2; 当事件RetrieveDataCompleted被触发时,处理程序运行的顺序是什么? 他们是否在同一个线程中运行,并按照已注册的顺序依次运行? 目前,它们是按照它们注册的顺序执行的。 但是,这是一个实现细节,我不会依赖这种行为在未来的版本中保持不变,因为它不是规范所要求的

Why does rand() + rand() produce negative numbers?

I observed that rand() library function when it is called just once within a loop, it almost always produces positive numbers. for (i = 0; i < 100; i++) { printf("%dn", rand()); } But when I add two rand() calls, the numbers generated now have more negative numbers. for (i = 0; i < 100; i++) { printf("%d = %dn", rand(), (rand() + rand())); } Can someone explain why I am seeing n

为什么rand()+ rand()产生负数?

我观察到rand()库函数在循环中只调用一次,它几乎总是产生正数。 for (i = 0; i < 100; i++) { printf("%dn", rand()); } 但是,当我添加两个rand()调用时,生成的数字现在有更多的负数。 for (i = 0; i < 100; i++) { printf("%d = %dn", rand(), (rand() + rand())); } 有人能解释为什么我在第二种情况下看到负数? PS:我将循环之前的种子初始化为srand(time(NULL)) 。 rand()定义为返回0到RAND_MAX之

rand() issue in C programming?

Possible Duplicate: Why do I always get the same sequence of random numbers with rand()? So yeah, this might seem slightly noobish, but since I'm teaching myself C after becoming reasonable at Java, I've already run into some trouble. I'm trying to use the rand() function in C, but I can only call it once, and when it do, it ALWAYS generates the same random number, which is 41. I

在C编程中的rand()问题?

可能重复: 为什么我总是用rand()获得相同的随机数序列? 所以是的,这看起来可能略微不明显,但是因为在Java变得合理之后我自学了C,所以我已经遇到了一些麻烦。 我试图在C中使用rand()函数,但是我只能调用它一次,并且当它执行时,它总是生成相同的随机数,这是41.我正在使用Microsoft Visual C ++ 2010 Express,并且我已经设置好了,所以它会编译C代码,但唯一不起作用的是这个rand()函数。 我试过包括一些常用

windows phone 8.1 header bar icon colours

My application is setting the Requested theme in the App.xaml as we only want to show a light theme regardless of what the user's system theme is. Problem is, when the user is on a dark theme (which has white icons for signal/battery/time etc) the app switches all style resources to use light theme but does nothing about the header bar. This creates the situation where you have a white pag

Windows Phone 8.1标题栏图标颜色

我的应用程序在App.xaml中设置了Requested主题,因为我们只想显示一个灯光主题,而不管用户的系统主题是什么。 问题是,当用户在一个黑暗的主题(它有白色的信号/电池/时间等图标)应用程序切换所有样式资源使用轻的主题,但没有关于标题栏。 这会造成您在白色背景上有白色图标的情况。 有没有办法改变应用于这个顶级栏的主题? 我尝试在酒吧后面添加深色(30px高的矩形,顶部带有-30边距),但行为也发生在轻量主题上,

How to define your own Windows 8 App Theme?

For a school assignement I'm doing some basic research on how Windows 8 Store App Development works. I followed the Hello World tutorial provided by Microsoft. The main themes you can use for the app are Light and Dark (and if I'm correct there's a third one High Contrast or something?), these are defined by MS. My question is, how can I create my own theme? I'd like to have

如何定义自己的Windows 8应用主题?

对于学校分配,我正在做一些关于Windows 8商店应用程序开发如何工作的基础研究。 我遵循微软提供的Hello World教程。 您可以用于应用程序的主要主题是Light and Dark(如果我是正确的,还有第三个高对比度或什么?),这些都是由MS定义的。 我的问题是,我如何创建自己的主题? 我想要有一个基本的应用程序主题与我定义的两个主要颜色。 我认为这是可能的,但我还没有找到任何方法。 在这里看到的是stackoverflow,但没有

Allowing users to customize theme colors

I have a windows 8.1 XAML application. I want to allow users to customize the theme of the app themselves - for example, I want to give them a color picker where they can set various colors in the app, which would set various resources used across my app. The issue though, is I cant find out how to dynamically change the value of a resource. I know in 8.1 they added the concept of a theme res

允许用户自定义主题颜色

我有一个Windows 8.1 XAML应用程序。 我想让用户自己定制应用程序的主题 - 例如,我想给他们一个颜色选择器,他们可以在应用程序中设置各种颜色,这将设置跨应用程序使用的各种资源。 问题虽然,我不知道如何动态地改变资源的价值。 我知道在8.1中他们添加了一个主题资源的概念,它允许我在运行时从轻到黑的主题变化,而不是。 但我的问题是,我想说'backgroundColor资源现在将变为橙色,并且使用此资源的所有项目都将

Make own windows 8 app theme

I'm working on an app, and want to apply my own style to it. XAML have something called theme directories which I trying to use for my themes. As it turns out, windows has 3 predefined themes; Light, Dark, and HighContrast. When I set the x:Key property on the Resource Directory containg the theme I want to use to something else than one of the 3 predefined or Default, it does not work.

制作自己的Windows 8应用主题

我正在开发一个应用程序,并希望将自己的风格应用于它。 XAML有一些称为主题目录的东西,我试图用于我的主题。 事实证明,Windows有3个预定义的主题; Light,Dark和HighContrast。 当我在资源目录上设置包含主题的x:Key属性时,我想将其用于除3个预定义或默认值之一以外的其他主题,但不起作用。 有人知道为什么 <ResourceDictionary.ThemeDictionary> <ResourceDictionary x:key="Default"> // Does work

ASP.NET MVC Conditional validation

How to use data annotations to do a conditional validation on model? For example, lets say we have the following model (Person and Senior): public class Person { [Required(ErrorMessage = "*")] public string Name { get; set; } public bool IsSenior { get; set; } public Senior Senior { get; set; } } public

ASP.NET MVC有条件验证

如何使用数据注释对模型进行条件验证? 例如,假设我们有以下模型(人员和高级): public class Person { [Required(ErrorMessage = "*")] public string Name { get; set; } public bool IsSenior { get; set; } public Senior Senior { get; set; } } public class Senior { [Required(ErrorMessage = "*")]//this should

Adding Zurb Foundation to a new asp.net webforms app

Can someone please tell me the proper way to add Zurb Foundation 5 CSS Framework to a new ASP.NET Application that is using the Webforms template and No Authentication. I would like to follow all of the conventions that microsoft put in place in this template such as bundles. I have attempted to do this and I keep getting errors in the js console. Here are the steps I took: Add new Webfor

将Zurb Foundation添加到新的asp.net webforms应用程序中

有人可以告诉我将Zurb Foundation 5 CSS Framework添加到使用Webforms模板和无身份验证的新ASP.NET应用程序的正确方法。 我想遵循微软在这个模板中使用的所有约定,比如捆绑包。 我试图做到这一点,我不断在js控制台中得到错误。 以下是我采取的步骤: 添加新的Webforms应用程序,无需身份验证。 从站点完全删除bootstrap。 从他们的网站下载Zurb Foundation 5(默认)。 将css和img文件夹添加到Content文件夹。