惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
P
Palo Alto Networks Blog
月光博客
月光博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
InfoQ
aimingoo的专栏
aimingoo的专栏
腾讯CDC
T
Threatpost
D
DataBreaches.Net
Vercel News
Vercel News
F
Fortinet All Blogs
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
Forbes - Security
Forbes - Security
U
Unit 42
C
Check Point Blog
Blog — PlanetScale
Blog — PlanetScale
O
OpenAI News
量子位
TaoSecurity Blog
TaoSecurity Blog
Microsoft Azure Blog
Microsoft Azure Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Visual Studio Blog
Recorded Future
Recorded Future
云风的 BLOG
云风的 BLOG
Security Archives - TechRepublic
Security Archives - TechRepublic
The Last Watchdog
The Last Watchdog
S
Security Affairs
Attack and Defense Labs
Attack and Defense Labs
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
小众软件
小众软件
S
SegmentFault 最新的问题
www.infosecurity-magazine.com
www.infosecurity-magazine.com
W
WeLiveSecurity
AI
AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 聂微东
I
Intezer
Know Your Adversary
Know Your Adversary
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
博客园_首页
NISL@THU
NISL@THU
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - skyfei

Xcode 文档注释方法 查看iOS模拟器应用的沙箱文件 Show in Finder OC代码 C# x86应用x64系统上读取x64位应用的注册表 Make webclient support upload the large file which are larger than 1G Shortcut key for WPF get Android information with adb, the build version Decodes a QuotedPrintable encoded string C# USB Detection - winform and WPF [转] 线程同步 转:C# Interview Questions Openxml: 导出excel 设置 cell的格式 - skyfei OpenXML: excel 插入BarChart图表 OpenXML: Asp.net利用OpenXML 导出Excel. TRIGGERS :Cannot use text, ntext, or image columns in the 'inserted' and ' deleted' tables. 'String or binary data would be truncated' error message .net Create Excel 2007 file with open xml 利用.Net Framework2.0 zip压缩、解压 string 数据 C#中文和UNICODE字符转换方法 - skyfei - 博客园
C# 常见面试题(2)
skyfei · 2009-12-23 · via 博客园 - skyfei

我上一篇随笔转了一篇C# 面试题合集(转:C# Interview Questions ), 但感觉还有些没有覆盖到, 有些是我平时没有注意到的,  特补充一下. 答案是我自己网络搜集理解, 不代表正确答案:

1. 线程之间如何通讯

一般而言,应用程序中的一个次要线程总是为主线程执行特定的任务,这样,主线程和次要线程间必定有一个信息传递的渠道,也就是主线程和次要线程间要进行通信。这种线程间的通信不但是难以避免的,而且在多线程编程中也是复杂和频繁的,下面将进行说明。

  •  使用全局变量进行通信

由于属于同一个进程的各个线程共享操作系统分配该进程的资源,故解决线程间通信最简单的一种方法是使用全局变量。对于标准类型的全局变量,我们建议使用volatile 修饰符,它告诉编译器无需对该变量作任何的优化,即无需将它放到一个寄存器中,并且该值可被外部改变。如果线程间所需传递的信息较复杂,我们可以定义一个结构,通过传递指向该结构的指针进行传递信息。 

  • 使用自定义消息

我们可以在一个线程的执行函数中向另一个线程发送自定义的消息来达到通信的目的。一个线程向另外一个线程发送消息是通过操作系统实现的。利用Windows操作系统的消息驱动机制,当一个线程发出一条消息时,操作系统首先接收到该消息,然后把该消息转发给目标线程,接收消息的线程必须已经建立了消息循环。

2. 线程之间如何同步

  • 临界区(CCriticalSection)
  • 事件(CEvent)
  • 互斥量(CMutex)
  • 信号量(CSemaphore)

    3.什么是委托delagte, delaget 和eventhandler 的关系  

    这是个老问题了, 每次都答不太明白

    MSDN : 委托是一种数据结构,它引用静态方法或引用类实例及该类的实例方法。  说白了也就是把方法引用封装成静态object, 这样实现跨线程之间的调用

    EventHandler 是一个预定义的委托,专用于表示不生成数据的事件的事件处理程序方法。如果事件生成数据,则必须提供自己的自定义事件数据类型,并且必须要么创建一个委托,其中第二个参数的类型为自定义类型.

    这里需要注意的是, eventhandler 是一个观察者模式.

    引申问题: 可以不用委托 实现 event 机制么?

     4.抽象类和接口的区别

    抽象类: 可以有构造析构函数, 可以有私有成员, 可以有具体的成员方法, 必须有一个或更多的虚方法, 只能单继承

    接口: 没有构造析构函数, 没有成员变量, 所有方法都是抽象方法, 可以多继承

    一般说来, 抽象类, 是对共同特点的提取, 是 "是什么" 的概念, 接口是属于 "能做什么的概念"

  • Asp.Net

    1. 什么是异步页面?

    asp.net中的异步页面 : http://www.cnblogs.com/ASPNET2008/archive/2009/02/23/1396673.html

    2.Fragment Caching

    • Fragment caching refers to the caching of individual user controls within a Web Form. 
    • Each user control can have independent cache durations and implementations of how the caching behavior is to be applied.
    • Fragment caching is useful when you need to cache only a subset of a page. 
    • Navigation bars, header, and footers are good candidates for fragment caching. 

    MSDN 查: OutputCache  指令