<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tamir Khason - Just code &#187; BLOG</title>
	<atom:link href="http://khason.net/category/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://khason.net</link>
	<description>Take care of the sense, and the sounds will take care of themselves.</description>
	<lastBuildDate>Wed, 25 Jan 2012 16:37:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to pass technical interview in Better Place</title>
		<link>http://khason.net/blog/how-to-pass-technical-interview-in-better-place/</link>
		<comments>http://khason.net/blog/how-to-pass-technical-interview-in-better-place/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 22:39:03 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[Better Place]]></category>
		<category><![CDATA[blogging general]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[promo]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://khason.net/blog/how-to-pass-technical-interview-in-better-place/</guid>
		<description><![CDATA[If you following me on Twitter, you probably know that we’re looking for developers. However those who was in interview here become a little bit shocked. It is not very standard interview for software houses. So how does it works? Step zero – requirements and open positions Even before somebody send us his/her resume there [...]<p/>]]></description>
			<content:encoded><![CDATA[<p>If you <a href="http://twitter.com/tamir" target="_blank">following me on Twitter</a>, you probably know that we’re looking for developers. However those who was in interview here become a little bit shocked. It is not very standard interview for software houses. So how does it works?</p>
<h3>Step zero – requirements and open positions</h3>
<p>Even before somebody send us his/her resume there are requirements and open positions. Those requirements are very straight forward: “We need a developer for servers” or “we need somebody to build UI” or “we need GIS guy” etc. All open positions (at least for Israel) you can always find in <a href="http://www.betterplc.co.il/category/career" target="_blank">our local website</a>. Those days we have two open positions for our team: <a href="http://www.betterplc.co.il/default.asp?catid={6A67D492-DBC7-44ED-A7EF-B315D4493C74}&amp;details_type=1&amp;itemid={12DABDD2-DB09-4077-91CA-7B06F04E9179}" target="_blank"><strong>super-fantastic developer</strong></a> and <a href="http://www.betterplc.co.il/default.asp?catid={6A67D492-DBC7-44ED-A7EF-B315D4493C74}&amp;details_type=1&amp;itemid={1AB37274-AF15-45D8-B652-E7961574B406}" target="_blank"><strong>chronic headache reliever</strong></a>.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="work in betterplace" src="http://khason.net/images/2009/07/image.png" border="0" alt="Tal who is our real time software integration engineers, learns Hebrew and looking for new girlfriend" title="Tal who is our real time software integration engineers, learns Hebrew and looking for new girlfriend" width="592" height="434" /></p>
<p>Now a bit about candidates. I had some developers hired during my career and it always worked following way: there are only 10 kinds of developers – developers and not. It never worked for me to hire somebody just because I have to hire somebody. Also it did not worked to hire mythological “average” or “rather good” developer. So for me the segmentation here is very binary- can write code or can not.</p>
<h3>Step one – CV</h3>
<p>Somebody told me that the only chance to hire good developer via CV is if the developer is student. However, and in spite of this the very first station is HR department, they get a ton of CVs each day and filter it out by using strange and mysterious heuristics. In most of cases it works like in bad search engine – by using keywords. So my very basic requirement from our HR team, please do not filter it this way because I’m working like SEO filter with those CVs by lowering rating of “<em>multi-threaded Design Patterns</em>”, “.NET 1,1.1,1.2,1.3,2.1.2.2.3.4.3.4.5.6.5.4.3 and dot.Net Remounting for Agile Ajax(tm) Web Services”, “deep knowledge and application of MFC, GUI, WinForms, C++, C#, HASP, SQL, ADO, OOP, ODP, IRC, TCP, HDTV, AX, DX, COM, VC++, API” and “Windows 3.11, 95, ME, 98, 98 SE, 2000, NT 3, NT 4.2, 2001, XP, XP SP1, SP2, SP3, 2008, 2010, Vista SP3 and DOS”.</p>
<p>Also candidate which “<em>management responsibility for the 26 software engineers (6 teams) located at India (Bangalore). Resources allocation for $1M budget and restructuring planning based on defined priorities</em>” probably won&#8217;t be developer, but want to be finance controller, because we was able to make 26 developers (even in India) to work for $38K a year including materials, living, facilities, etc.</p>
<p>So a small tip for your CV, please write what you did (yes, it is not shame if you never heard about OOP/ODP, but knows how and when it should be <em>virtual</em> and when <em>abstract</em>).This way you’ll not waste your and your future employer time.</p>
<h4>Step two – Phone call</h4>
<p>If CV is readable and clear for me, I’m calling the person. Usually it takes under 5 minutes to invite him/her or not for frontal interview. However sometimes it can take even half an hour. I am not asking the same questions, this because it is impossible to ask the same somebody who write smart client applications and those from web planet. I almost never ask a candidate to repeat what he/she just told. The only exception is when I am not understand the answer. However when the candidate asks relevant questions it is big plus for him.</p>
<p>The general set of questions contains of three main sections: what exactly you did (even if it clear from CV), what are you looking for and whether you want to work in Better Place.</p>
<p>The phone call ends by taking one of four direction: invite for frontal interview (jump to step 3.1), invite for technical exam (jump to step 3.2), send home work to prepare (non-blocking wait for a year or two) or “we’ll be in touch” by transferring the candidate with mark “negative” to HR (end of the process). They know how to tell them.</p>
<h4>Step three point one – Frontal interview</h4>
<p>Frontal interview is usually takes between an hour and an hour and a half. It contains of general CS questions like <a href="http://khason.net/tech/brilliant-yet-simple-technical-questions-can-be-used-for-work-interview/" target="_blank">those</a>. Also question to understand whether the candidate is developer or “code-monkey” &#8211; one who does not know what the difference between scalar and vector or how to convert float to int faster then using “corporate frameworks developed by other team”. The thumb rule is simple &#8211; if each question takes more then 10 seconds to answer the candidate does not really knows the topic. In spite of this, I allow about a minute for each answer.</p>
<p>Next section is related to specific domain of the candidate. It might be architectural overview of one of his/her solutions, all he/she knows about inheritance (why, how, multiple, virtual, public, etc). Constructors/destructors/templates/generics/allocations/virtual inheritance is a next part. What is “new” and why we need it. How to cleanup remindings and how it works in real life (even if you thought that it should be done automagically). Special bonus for those who knows what interrupts and registers are and how it really works under the hood.</p>
<p>If the candidate good enough we keep going toward data structures. This includes linear/random access, hash, trees (with different colors), search vs seek vs lookup with yield return bonus. What is special about “string”. Lazy invocation vs evaluation, alloc/malloc (if relevant), lifetime.</p>
<p>If the candidate is especially good we can start speaking the target language (sometimes it’s assembler and sometimes is C# or even Python [I can speak some <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ]).</p>
<h4>Step three point two – Technical exam</h4>
<p>Sometimes, when it is not very clear whether the candidate is programmer, I’m asking for write a small program from scratch without using standard libraries. For less developer position I’m asking to find a number of bugs in real code (which includes required bugs <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). Code is different for different levels of programmers. Also in most cases a candidate can use any computer language he/she wants.</p>
<p>To prepare such exam we need to work very hard. First of all (and before it comes to candidates) we’re sending it to all developers in similar positions and asking them to do it. Then we are measuring time and multiply it by 2. Also we’re writing down all question, asked by developers and trying to fix description to answer all commons.</p>
<p>Candidate got new clean machine, empty silent room with air conditioner and can use any information sources he/she wants in order to do the exam. It can be internet, friends, books, etc. However it is not so simple as it looks. Each candidate has final time to write the program. It takes longer to find the “similar” solution and adopt, rather then do it yourself.</p>
<p>We are require three hours to finish current exam (it took about an hour to finish it for me, and hour and a half in average for the company). If the candidate finished it before the time he/she got a bonus point. If he/she wrote “almost the same code” – failed, “almost finished” or “almost works” – failed, “has not enough time” – failed, two significant bugs – failed, “the question was not clear” – failed, “did not know who to ask” – failed, etc.</p>
<p>It’s amazing how hard for some code-monkeys not to use standard libraries. Sometimes it is too hard for bad programmers to understand that not all computer languages has arrays and collections, sometimes, it’s too hard to realize that if you not really understand what inheritance is you have to write the same procedure more then once.</p>
<p>But not only the exam determinates the future of the candidate. Sometimes (in very rare cases) we’re wrong with this test and do not filter out bad programmer. It is very hard to lay out him later, but because of such person you will not finish project at time, or will do it overbudget. Thus we prefer not to hire, then to fire. This why we have additional step.</p>
<h4>Step three point three – Another interview</h4>
<p>It is very important to emphasize that we have about 0.05% of those who where at stage three point one. This interview can take upto full day. You should come ready for this. Plan and watch each of your steps. Also you should be ready to speak with number of people near flip charts, whiteboards, calculators, computers and other hardware things. Also you should be ready to assert your opinion.</p>
<p>Most of people you’ll speak with will be very smart (this is not restricted to your direct manager or future colleague only). Sometimes you’ll speak with two or three people at simultaneously. Each person will have his own very special opinion. Also the questions may wary from base calculations to mechanical and electronic schematics or references of your vehicle.</p>
<p>You can take timeout, however take into account that people speaking with your sacrificing their time and projects, so you should consider it.</p>
<h4>Step four – final</h4>
<p>If you passed all three previous steps – you can consider yourself as our future employee. There were only once, when we had not hire developer because of financial/welfare issue. This because of our stances of good developers. If you did not hire them – you and all company will loose, not the developer. Each of those will find his/her place very soon. Even if the good developer has no CV at all or he/she is a student or foreign resident. Because the only chance for this company to produce good results is to have good human resources.</p>
<h3>Send me your CV or contact me <span style="text-decoration: underline;"><span style="color: #000080; font-size: large;">tamir [AT] khason.biz</span></span> to tell that you are the one I’m looking for &gt;&gt;</h3>
<p><em>Please do not send me your CV if it passes the regex of the first step – just send a message with list of what you did for last 7 years.</em></p>
<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/how-to-pass-technical-interview-in-better-place/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Windows 7 &#8211; dry run or how things should be done to correct old mistakes</title>
		<link>http://khason.net/blog/windows-7-dry-run-or-how-things-should-be-done-to-correct-old-mistakes/</link>
		<comments>http://khason.net/blog/windows-7-dry-run-or-how-things-should-be-done-to-correct-old-mistakes/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 20:47:23 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[TECH]]></category>
		<category><![CDATA[VIDEO]]></category>
		<category><![CDATA[blogging general]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[promo]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://khason.net/blog/windows-7-dry-run-or-how-things-should-be-done-to-correct-old-mistakes/</guid>
		<description><![CDATA[I have not write for a while (if you’re following me on Twitter, you know why). Even so, today it will not be very informative post. This all about my expression about latest builds of Windows 7 and one job proposal. Have a fun. January 13rd, I expressed rather bad opinion about Windows 7 (beta [...]<p/>]]></description>
			<content:encoded><![CDATA[<p>I have not write for a while (if you’re <a href="http://twitter.com/tamir" target="_blank">following me on Twitter</a>, you know why). Even so, today it will not be very informative post. This all about my expression about latest builds of Windows 7 and one job proposal. Have a fun.</p>
<p><a href="http://khason.net/itpro/windows-7-dry-run-or-why-intel-does-not-like-microsoft/">January 13rd, I expressed rather bad opinion about</a> <a href="http://khason.net/tag/windows-7/">Windows 7</a> (beta those days). Today, after most of post-RC builds (currently with 7260) on work machine I would way with big confidence – <strong>Microsoft learned from beta errors and now it works almost like it should work for RTM</strong>.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="6.1.7260.0.win7_rtm.090612-2110" border="0" alt="6.1.7260.0.win7_rtm.090612-2110" src="http://khason.net/images/2009/06/image.png" width="469" height="409" /> </p>
<h3>Installation</h3>
<p>Installation takes less and less from build to build (this is 7th I’m checking). With 7260 it took about 15 minutes. All hardware devices (including Intel AMT, PM45 and LM5) were found and installed correctly. Shortly after the installation it installed a bunch of security and device driver updates. Looks like Microsoft has no issues with Intel anymore (or they just decided to build drivers by itself).</p>
<p>Hybrid graphic cards still not supported. Also it not seemed that it will be supported toward RTW. However Windows 7 correctly decided to use discrete card, rather then on-board once BIOS settings were set to prioritize it.</p>
<h3>Taskbar</h3>
<p>It still sucks, but you will accustom to it. From the beginning it looks like it takes all valuable space on your desktop, but shortly after you’ll see that it somehow comfortable to use it (it is really depends how you working. Lately I changed a bit a way I’m doing things [this why you cannot see me in Live Messenger anymore], thus it become rather good for me). Here how it looks for me now</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="My taskbar - in battery save mode of couse" border="0" alt="My taskbar - in battery save mode of couse" src="http://khason.net/images/2009/06/image1.png" width="77" height="542" /> </p>
<p>Yes, it is Chome on this bar and this why:</p>
<h3>‘Coz Internet Explorer become worse and worse</h3>
<p>The only good thing I found about IE8 shipped with W7 is it has support for Windows 7 taskbar. However even this fact cannot defense against its suckness. It slow, buggy, has not enough functionality and absolutely annoying. I love Firefox, but it has too much functionality for me those days. Once I used to open it, I loss at least a half of hour <a href="http://khason.net/blog/line-of-business-vs-beautifulness-or-two-dogmas-comparison-as-exemplified-by-two-twitter-applications/">for twittering</a>, reading rss, etc. With Google Chrome is it not an issue, because this is nimble program with only one functionality – browse internet pages.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:329cfe93-ef30-4387-bbea-4b94d7e9cc0a" class="wlWriterEditableSmartContent">
<div><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/o4MwTvtyrUQ&amp;hl=en"></param><embed src="http://www.youtube.com/v/o4MwTvtyrUQ&amp;hl=en" type="application/x-shockwave-flash" width="425" height="355"></embed></object></div>
</div>
<h3>My last BSoD</h3>
<p>Since the last time, I had no BSoDs. Also WDM not eating 999.9 CPU hours anymore (like it did in idle Vista). Also I had no compatibility issues. Everything worked as expected on my machine. The only issue I had is IE, that decided not to die and stuck as running windowless process. You know how it is when any icon on taskbar stops to do anything, just becoming red when you click on it.</p>
<h3>Conclusion</h3>
<p>Do it. Upgrade your OS as soon as possible and have a fun.</p>
<p>&#160;</p>
<h2>We’re hiring! (Israel residents only)</h2>
<h3>Lead Software Development Engineer in Test</h3>
<p>We are looking for strong Software Development Engineer in Test who is passionate about UI and internal API usage to test rich client applications. Responsibilities would include developing test strategies, writing unit tests, UI automation, custom msbuild scripts, performing problem isolation and analysis, communicating with developers in support of debugging and investigation.</p>
<p>My group takes both individuals and teams success seriously, and looking for the right person to join our team, which is development, rather than test team. What my group is doing?</p>
<p>The AutOS group is responsible for delivering of the system you’ll have inside your next electric vehicle, one of the most important applications we have at <a href="http://betterplace.com" target="_blank">Better Place</a> for providing a consistent, transparent and fluent experience for a driver every day. Currently the application is used for energy management, navigation, infotainment, road safety and many other aspects of enhancing your future driving. Come explore the exciting opportunities on AutOS team developing cutting edge tools, facing all customers for all Better Place EVs. Become a member of the outstanding team that strives for engineering excellence in improving the life of all of us. AutOS team is using latest technologies and innovations to make sure delivery of the best possible experience for a driver.</p>
</p>
<h4>Qualification</h4>
<p>Solid programming ability in managed programming using the .NET Framework (C#) with some experience in WPF or Silverlight.   <br />Solid technical knowledge in Information Technology field, including hardware capabilities and performance evaluation and tests.    <br />Strong problem solving and troubleshooting skills.    <br />Knowledge of Team Foundation Server and MSBUILD scripting.    <br />2+ years experience in software testing, including designing and developing automation infrastructure.    <br />Strong test aptitude.    <br />Good communication skills and ability to work closely in a development team environment.    <br />BA/BS or MS degree in Computer Science or equivalent field experience is required.</p>
<p><strong>You think, that you want such job? Send me your CV, couple of word about yourself and why you want and able to work with me at Better Place to </strong><a href="mailto:tamir@khason.biz"><strong>tamir@khason.biz</strong></a><strong> with “Lead SDET application” in subject. </strong><em>(if you do get get an answer from me within a week, your mail is in spam, so you should resent it by using <a href="http://khason.net/tamir/" target="_blank">contact form here</a>)</em></p>
<p>Have a nice day and be good people.</p>
<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/windows-7-dry-run-or-how-things-should-be-done-to-correct-old-mistakes/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Book review: C# 2008 and 2005 Threaded Programming</title>
		<link>http://khason.net/blog/book-review-c-2008-and-2005-threaded-programming/</link>
		<comments>http://khason.net/blog/book-review-c-2008-and-2005-threaded-programming/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 21:42:28 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[blogging general]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PLINQ]]></category>
		<category><![CDATA[promo]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[TECH]]></category>
		<category><![CDATA[thoughts]]></category>

		<guid isPermaLink="false">http://khason.net/blog/book-review-c-2008-and-2005-threaded-programming/</guid>
		<description><![CDATA[A couple of weeks ago, Packt publishing asked me to review Gastón C. Hillar book “C# 2008 and 2005 Threaded Programming: Beginner&#8217;s Guide”. They sent me a copy of this book and today, I’m ready to write a review for it. But before I’ll start reviewing it, I want to apologize to the publisher and [...]<p/>]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago, <a href="http://www.packtpub.com/" target="_blank">Packt publishing</a> asked me to review Gastón C. Hillar book “<a href="http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book" target="_new">C# 2008 and 2005 Threaded Programming: Beginner&#8217;s Guide</a><img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" height="1" alt="" src="http://www.assoc-amazon.com/e/ir?t=israkniga-20&amp;l=as2&amp;o=1&amp;a=1847197108" width="1" border="0" />”. They sent me a copy of this book and today, I’m ready to write a review for it. But before I’ll start reviewing it, I want to apologize to the publisher and author for the impartial review.</p>
<p><a href="http://www.amazon.com/gp/product/1847197108?ie=UTF8&amp;tag=israkniga-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1847197108" target="_new"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="420" alt="image" src="http://khason.net/images/2009/03/image.png" width="340" border="0" /></a></p>
<p>First of all, you should understand, that <a href="http://www.amazon.com/gp/product/1847197108?ie=UTF8&amp;tag=israkniga-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1847197108" target="_new">this book</a> is about <strong>how</strong> it possible (for this book author) to write four programs (with awful user interface) using different classes from System.Threading namespace to perform tasks, rather then <strong>what </strong>is multithreaded programming and how to achieve best performance by utilizing multiple CPU power. Your own programs will not run faster after reading this book, but you’ll probably know (if you did not know before) how to use <a title="Read MSDN documentation about System.ComponentModel.BackgroundWorker class" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" target="_blank" rel="tag">BackgroundWorker</a>, <a title="Read MSDN documentation about System.Threading.Thread class" href="http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx" target="_blank" rel="tag">Thread</a>, <a title="Read MSDN documentation about System.Threading.ThreadPool Class" href="http://msdn.microsoft.com/en-us/library/system.threading.threadpool.aspx" target="_blank" rel="tag">ThreadPool</a>, <a title="Read MSDN documentation about System.Threading.AutoResetEvent Class" href="http://msdn.microsoft.com/en-us/library/system.threading.autoresetevent.aspx" target="_blank" rel="tag">AutoResetEvent</a> and <a title="Read MSDN documentation about System.Threading.WaitHandle Class" href="http://msdn.microsoft.com/en-us/library/system.threading.waithandle.aspx" target="_blank" rel="tag">WaitHandle</a> classes. Also, there is a small chapter about thread context switching for UI thread delegates invocation and <a href="http://msdn.microsoft.com/en-us/concurrency/default.aspx" target="_blank">parallel extensions</a>.</p>
<p>There are some technical misconceptions and errors in this book. But it is not the major problem of it. The problem is that while reading this book I question myself whom this book aimed at? Language style is somewhere between blog chatting (better then mine) and <a href="http://msdn.microsoft.com/en-us/library/ms684841(VS.85).aspx" target="_blank">MSDN style documentation</a>. I admit I don’t know quite how to categorize this, the author writes in a style that is just bizarre (even more bizarre then mine in this blog <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) Overall, it sounds like I’m reading a conversation between two beginner-level programmers trying to explain one each other why they are using certain coding convention in C#.</p>
<p>Another half of this 395 pages book is just copy-paste stuff from Visual Studio (including it default tabulations and indentations). Here one of representative examples of such copy/paste</p>
<blockquote><p>// Disable the Start button      <br />butStart.Enabled = false;       <br />// Enable the Start button       <br />butStart.Enabled = true;       </p>
<p>…       </p>
<p>// Some very useful property, which used as private member for another public property       <br />private int priVeryUserfulProperty; </p>
</blockquote>
<blockquote><p>public int VeryUserfulProperty      <br />{       <br />&#160;&#160; get       <br />&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160; return priVeryUserfulProperty;       <br />&#160;&#160; }       <br />&#160;&#160; set       <br />&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160; priVeryUserfulProperty = value;       <br />&#160;&#160; }       <br />}</p>
</blockquote>
<p><strong>Verdict</strong>: Not very exemplary introduction to some classes inside System.Threading namespace for fellow students who like to read blogs, rather then books and documentation and do not want to understand how it works under the hoods, but write something and forget it. </p>
<p><strong>3- of 5</strong> on my scale. <a href="http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book" target="_blank">This book</a> is not <strong>all</strong> bad, though, but apparently suitable for very specific audience, which definitely excludes me.</p>
<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/book-review-c-2008-and-2005-threaded-programming/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Finally I can reveal stuff I working for last half year!</title>
		<link>http://khason.net/blog/finally-i-can-reveal-stuff-i-working-for-last-half-year/</link>
		<comments>http://khason.net/blog/finally-i-can-reveal-stuff-i-working-for-last-half-year/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 17:19:39 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[blogging general]]></category>
		<category><![CDATA[demos]]></category>
		<category><![CDATA[My tools]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[promo]]></category>
		<category><![CDATA[soft]]></category>
		<category><![CDATA[Work process]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://khason.net/blog/finally-i-can-reveal-stuff-i-working-for-last-half-year/</guid>
		<description><![CDATA[A couple of days ago WordFocus exposed one of our (frankly old ) WPF prototypes for in-car energy assistant system, so today I can exclusively show you some of screens from this state of art WPF work. Real time performance of WPF touch screen application, running on low power automotive grade PC, which boots faster, [...]<p/>]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago <a href="http://worldfocus.org/blog/2009/02/09/israeli-company-builds-infrastructure-for-worlds-electric-cars/3977/" target="_blank">WordFocus exposed</a> one of <a href="http://www.betterplace.com/" target="_blank">our</a> (frankly old <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) <a title="See all WPF related posts" rel="tag" href="http://khason.net/tag/wpf/" target="_blank">WPF</a> prototypes for in-car energy assistant system, so today I can exclusively show you some of screens from this state of art WPF work. Real time performance of WPF touch screen application, running on low power automotive grade PC, which <a href="http://khason.net/blog/what-boots-faster-%e2%80%93-netbook-powered-windows-xp-or-nokia-e71-mobile-phone/" target="_blank">boots faster, then Nokia phone</a>. Huge respect for all developers and P-defs.</p>
<p><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="Map overview" src="http://khason.net/images/2009/02/c1.jpg" border="0" alt="Map overview" width="640" height="432" /></p>
<p><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="Planning screen" src="http://khason.net/images/2009/02/c2.jpg" border="0" alt="Planning screen" width="640" height="434" /> <img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="Navigation draving state" src="http://khason.net/images/2009/02/c9.jpg" border="0" alt="Navigation draving state" width="640" height="430" /></p>
<p><img style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" title="Applications" src="http://khason.net/images/2009/02/c6.jpg" border="0" alt="Applications" width="640" height="436" /></p>
<p>Full video report by <a href="http://worldfocus.org/" target="_blank">WorldFocus.org</a></p>
<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/finally-i-can-reveal-stuff-i-working-for-last-half-year/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Slides and desks from Smart Client Development session</title>
		<link>http://khason.net/blog/slides-and-desks-from-smart-client-development-session/</link>
		<comments>http://khason.net/blog/slides-and-desks-from-smart-client-development-session/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 09:59:57 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[DEV]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[promo]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://khason.net/?p=2104</guid>
		<description><![CDATA[Great thank to everybody attended yesterday at &#8220;Smart Client development&#8221; session. As promises, please see slides and desks from this session Smart Client Development View more presentations from tamirk. (tags: wpf israel)<p/>]]></description>
			<content:encoded><![CDATA[<p>Great thank to everybody attended yesterday at <a href="http://khason.net/blog/action-required-smart-client-development-present-and-future/">&#8220;Smart Client development&#8221; session</a>. As promises, please see slides and desks from this session</p>
<div id="__ss_1019853" style="width: 425px; text-align: left;"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" title="Smart Client Development" href="http://www.slideshare.net/tamirk/smart-client-development?type=presentation">Smart Client Development</a><object width="425" height="355" data="http://static.slideshare.net/swf/ssplayer2.swf?doc=0802-smart-client-development-1234429782979672-1&amp;stripped_title=smart-client-development" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=0802-smart-client-development-1234429782979672-1&amp;stripped_title=smart-client-development" /><param name="allowfullscreen" value="true" /></object></p>
<div style="font-size: 11px; font-family: tahoma,arial; height: 26px; padding-top: 2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/tamirk">tamirk</a>. (tags: <a style="text-decoration:underline;" href="http://slideshare.net/tag/wpf">wpf</a> <a style="text-decoration:underline;" href="http://slideshare.net/tag/israel">israel</a>)</div>
</div>
<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/slides-and-desks-from-smart-client-development-session/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Math world, simple mental calculations or what&#8217;s going on with education?</title>
		<link>http://khason.net/blog/math-world-simple-mental-calculations-or-whats-going-on-with-education/</link>
		<comments>http://khason.net/blog/math-world-simple-mental-calculations-or-whats-going-on-with-education/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 13:07:55 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[blogging general]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[quiz]]></category>
		<category><![CDATA[thoughts]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://khason.net/blog/math-world-simple-mental-calculations-or-whats-going-on-with-education/</guid>
		<description><![CDATA[Today, I want to write blog post which is absolutely not related to programming. It related to math and education in general those days. During work interviews, I see a lot of people, who was absolutely unable to calculate mentally. They just can’t understand, that it’s possible to do without calculators. When my kids (2nd, [...]<p/>]]></description>
			<content:encoded><![CDATA[<p>Today, I want to write blog post which is absolutely not related to programming. It related to math and education in general those days. During <a href="http://khason.net/tech/brilliant-yet-simple-technical-questions-can-be-used-for-work-interview/" target="_blank">work interviews</a>, I see a lot of people, who was absolutely unable to calculate mentally. They just can’t understand, that it’s possible to do without calculators. When my kids (2nd, 6th and 7th grade) were small I taught them to play with numbers, and until 4th grade (bigger kids) they were able do it. but then school teachers “killed” this ability. Why people should use calculator for simple math operations, if he can do it mentally? Shame you, the modern educational system. Let’s go back and try to understand how people were able to live without devil devices, such as calculators…</p>
<p>Following the paint of <a href="http://en.wikipedia.org/wiki/Nikolai_Bogdanov-Belsky" target="_blank">Nikolai Bogdanov-Belsky</a> “Counting in their heads”. This painting is dated 1895.</p>
<p><img title="Богданов Бельский - Устный счёт" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="570" alt="Богданов Бельский - Устный счёт" src="http://khason.net/images/2009/02/image1.png" width="714" border="0" /> </p>
<p>As you can see at the painting, peasant kids trying to solve following exercise mentally:</p>
<blockquote><p>(10<sup>2</sup> + 11<sup>2</sup> + 12<sup>2</sup> + 13<sup>2</sup> + 14<sup>2</sup>) / 365</p>
</blockquote>
<p>This is not very simple exercise, especially when should be solved without your favorite calculator. However, when I was 4th grade I learned to square two-digit numbers mentally (my, and I think, yours too): <strong>First, find the nearest multiple of ten, by raising or lowering your number, then add and remove the rest to each of numbers and add the square of oddment</strong>. For example</p>
<blockquote><p>45 * 45 = (45+5) * (45-5) + (5 * 5) = 50 * 40 + 25 = (5 * 4) * 100 + 25 = 20 * 100 + 25 = 2000 + 25 = 2025      <br />14 * 14 = (14+4) * (14-4) + (4 * 4) = 18 * 10 + 16 = 180 + 16 = 196</p>
</blockquote>
<p>So, now it can be solved easily:</p>
<blockquote><p>10<sup>2</sup> = 100       <br />11<sup>2</sup>= (11+1) * (11-1) + 1 = 12 * 10 + 1 = 121      <br />12<sup>2</sup>= (12+2) * (12-2) + 4 = 14 * 10 + 4 = 144      <br />13<sup>2</sup>= (13+3) * (13-3) + 9 = 16 * 10 + 9 = 169      <br />14<sup>2</sup>= (14+4) * (14-4) + 16 = 18 * 10 + 16 = 196</p>
</blockquote>
<p>And so on… but wait, 100+121+144 already equals 365, which is our denominator. Next sequence will bring us 169+196, which is also 365. So the answer to this black board brain teaser is 2.</p>
<p>However, it can be rather complicated to calculate 86<sup>2</sup> for instance:</p>
<blockquote><p>86<sup>2</sup> = (86 + 4) * (86 – 4) + (4 * 4) = 90 * 82 + 16…</p>
</blockquote>
<p>Let’s try another way – <strong>multiple the difference between the number and 25 by 100, then add the square of the difference or excess of the number and 50</strong>. For example</p>
<blockquote><p>86<sup>2</sup> = (86 – 25) * 100 + (86 – 50)<sup>2</sup> = 61 * 100 +&#160; 36<sup>2</sup> = 6100 + (36 – 25) * 100 + (50 &#8211; 36)<sup>2</sup> = 6100 + 1100 + 14<sup>2</sup> = 7200 + 196 = 7396</p>
</blockquote>
<p>Isn’t it really simple and fun to calculate squares of numbers?</p>
<p><em>Bonus</em>: how to calculate multiple of two digit numbers with the sum of its unity digits equals to 10? </p>
<ol>
<li>Multiply first digit of the first number by 10</li>
<li>Add 1 to first digit of second number and multiply the result by 10</li>
<li>Multiply results of step 1 and step 2</li>
<li>Deduct second number and the result of step 1</li>
<li>Multiply second digit of the first number by the result of step 4</li>
<li>Add results of steps 3 and 5</li>
</ol>
<p>Looks complicated? Let’s make it easier. Assuming that first number is X = 10x + z and second number is Y = 10y + (10 – z), the formula for quick multiplication calculation is: <strong>100 * x * (y + 1) + z * (Y – 10 * x)</strong>. For example:</p>
<blockquote><p>96 * 84 = 100 * 9 * (8+1) + 6 * (84-10 * 9) = 100 * 9 * 9 + 6 * (84 – 90) = 8100 – 6 * 6 = 8100 – 36 = 8064     <br />37 * 93 = 100 * 3 * (9+1) + 7 * (93 – 10 * 3) = 3000 + 7 * 63 = 3000 + (100 * 6 * 1 + 3 * (7 – 60)) = 3000 + 600 – 3 * 53 = 3600 – 159 = 3441</p>
</blockquote>
<p>Have a nice day and be good people. Also, throw out all hardware calculators and uninstall all software <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/math-world-simple-mental-calculations-or-whats-going-on-with-education/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Line-Of-Business vs. Beautifulness or two dogmas comparison as exemplified by two Twitter applications</title>
		<link>http://khason.net/blog/line-of-business-vs-beautifulness-or-two-dogmas-comparison-as-exemplified-by-two-twitter-applications/</link>
		<comments>http://khason.net/blog/line-of-business-vs-beautifulness-or-two-dogmas-comparison-as-exemplified-by-two-twitter-applications/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 08:03:48 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[blogging general]]></category>
		<category><![CDATA[blogging tools]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[soft]]></category>
		<category><![CDATA[thoughts]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Windows Gadgets]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://khason.net/blog/line-of-business-vs-beautifulness-or-two-dogmas-comparison-as-exemplified-by-two-twitter-applications/</guid>
		<description><![CDATA[Today I want to speak about two dogmas: design and functional driven programming. As the example of those two approaches, I want to introduce two Twitter clients: *Chirp by thirteen23 and TwitterFox by Naan Studio As you can see, *Chirp is state of art application with outstanding user interface, and well-defined usability studies. While TwitterFox [...]<p/>]]></description>
			<content:encoded><![CDATA[<p>Today I want to speak about two dogmas: design and functional driven programming. As the example of those two approaches, I want to introduce two Twitter clients: <a href="http://www.thirteen23.com/experiences/desktop/chirp/" target="_blank">*Chirp by thirteen23</a> and <a href="http://twitterfox.net/" target="_blank">TwitterFox by Naan Studio</a></p>
<p><img title="Chirp and TwitterFox comparision" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="651" alt="Chirp and TwitterFox comparision" src="http://khason.net/images/2009/01/image26.png" width="664" border="0" /> </p>
<p>As you can see, *Chirp is state of art application with outstanding user interface, and well-defined usability studies. While TwitterFox is wacky grey boring kind-of-grid only. However, you cannot judge app by only how it looks like. Let’s try to understand first what’s for you need twitter client?</p>
<h3>Defining application goals by user story</h3>
<p><a href="https://twitter.com/tamir" target="_blank">I’m using twitter</a> as quick and handy business tool to write my thought, feelings and everyday events. It is not my main (not even secondary) task during the day, so I want to be able to open, write and forget. Thus, I need an application, that can be invoked by one click and dismissed after writing. Also, I do not want background application to gasp valuable space in my screen, when not in use. Thus it should be background process with reduced workset and one textarea, to be focused when the main window become active. Also the application should hide itself when unfocus, yet be able to notify me about events without disturbing. </p>
<p>Let’s see how it done in *Chirp:</p>
<ul>
<li>140MB workset</li>
<li>No ability to hide</li>
<li>Bouncing thingy at left upper corner to disturb you – it designed as you main desktop beautifier.</li>
<li>No ability to know that new twittes arrived without showing main window</li>
<li>Twit process required to click additional button (named “Update” for some reason)</li>
<li>If you not finished typing, you can either dismiss all text of post it.</li>
<li>Strange 140 characters countdown on background absolutely esthetical, yet very disturbing.</li>
<li>You cannot type more, then 140 characters – this restricted by textbox. If pasted bigger text all additional characters truncated.</li>
<li>You need mouse to operate an application</li>
</ul>
<p>Now TwitterFox:</p>
<ul>
<li>10MB workset</li>
<li>You can hide it by hitting escape or clicking X button</li>
<li>Small and portable without disturbing elements – it not designed as your main everyday app.</li>
<li>New twits counter over small icon in browser tray, all other notifications can be disabled</li>
<li>Once focused text are become active, expanded automatically and ready to write</li>
<li>If you’re hiding it without clearing area, all un write text remains – you can clear it by one click</li>
<li>Small 140 characters countdown which is visible only when typing</li>
<li>You can type more, then 140 characters – counter becomes red, and you cannot post, however you’re able to fix, by dismissing unnecessary spaces or characters.</li>
<li>Can be operated by only keyboard.</li>
</ul>
<p><strong>Bottom line</strong>: *Chirp designed to show how good it looks, while TwitterFox to twit only. Thus for my specific user story TwitterFox won!</p>
<h3>Defining functional specifications</h3>
<p>Next task defined for Twitter is read other twits. I used to read all my following and followers when I have free minute. Sometimes I retwit things, rather often reply followers and read replies and rarely send direct messages. </p>
<p>*Chirp provides twit area without scrollbar, yet not restricted to number of twits. Other words, you can scroll with mouse wheel only or by holding somewhere inside and dragging unlimited up and down. When the mouse is over specific twit, it fades and show three buttons: reply, direct and retwit. Also each twit contains the name of the client was used (just like in regular web interface). When clicking user avatar it brings to special internal screen with last twit of the user, information and statistics about him, three functional buttons: UnFollow, Fave and Block and huge button Get User’s Tweets. When clicking the line displays the time of the twit it puts twit url into clipboard.</p>
<p>Also *Chirp contains five main functional buttons: Faves, Home, Direct, Update and Refresh. When Home tab unfocused (for example you’re on other screen), it also displays a number of new twits. </p>
<p>Error screen of *Chirp is really odd. It contains everything you not really need to know and beautiful whales moving on screen.</p>
<p><img title="WTF?" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="458" alt="WTF?" src="http://khason.net/images/2009/01/image27.png" width="305" border="0" /> </p>
<p>TwitterFox is much simpler. It contains two buttons on mouse/keyboard over – reply and fave. When clicking on user’s avatar it opens it’s page in Twitter with all necessary information. Main TwitterFox window contains three buttons: Recent, Replies, Messages.</p>
<p>No doubt, that *Chirp provides much richer functional spec, but wait, am I really need all this? I told earlier, that I used to read twits and replies, while *Chirp has no such view at all. You can easy copy twit url into clipboard, but what for? Also, you can read&#160; bio and statistics of people you following whenever you want without opening browser window. But how often you’re doing that?</p>
<p>TwitterFox concentrated on functionality – twit, read, reply, read replies (and direct messages) – base tasks , Twitter designed for. It also marks replies with contrast color in public timeline, while *Chirp has inline reply functionality with threaded discussions support (which is very odd for Twitter)</p>
<p><strong>Bottom line</strong>: *Chirp is enriched with not useful features, while TwitterFox contains only things, you’re use. Thus for my specific functional requirements TwitterFox won again!</p>
<h3>Developers vs. Designers final round</h3>
<p>So, we already understand, that *Chirp is an application, designed to show how skilled <a href="http://www.thirteen23.com/" target="_blank">thirteen23</a> designers are. And it achieved this goal. The application is state-of-art, looks and designed very well with taking into account even small details, however it huge, unusable for everyday twittering and extremely slow. This is a general example about Designers’ doctrine.</p>
<p>TwitterFox is very ugly, but concentrated on functionality, tiny and reactive. It includes only features are necessary for twittering and has no other goals. So, this is a general example about Developers’ doctrine.</p>
<p>Is it possible to messmate those doctrines? Probably it is. And it is really simple. Each one of actors should do his own work. Designers should design and Developers – develop. I spoke about it a lot during my lectures, I’ll speak about it also at <a href="http://khason.net/blog/action-required-smart-client-development-present-and-future/" target="_blank">11th February in user group meeting</a>. By now, when you know how I see Twitter, <a href="https://twitter.com/tamir" target="_blank">you can start following me</a>. Also, I’m interesting to hear your ideas about Designer-Developer intercommunication. It is not just about Microsoft way <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img title="Designer and Developer - Microsoft way" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="207" alt="Designer and Developer - Microsoft way" src="http://khason.net/images/2009/01/image28.png" width="419" border="0" /> </p>
<p>Have a nice day and be good people.</p>
<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/line-of-business-vs-beautifulness-or-two-dogmas-comparison-as-exemplified-by-two-twitter-applications/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Action required: Smart Client development present and future</title>
		<link>http://khason.net/blog/action-required-smart-client-development-present-and-future/</link>
		<comments>http://khason.net/blog/action-required-smart-client-development-present-and-future/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 14:07:10 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[promo]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://khason.net/blog/action-required-smart-client-development-present-and-future/</guid>
		<description><![CDATA[Are you in Israel 11-February evening? Are you smart client developer and think, like me, that “cloud thingy” is just like Playboy girl, whom you never know what surprises might be waiting for you underneath? If so, you are invited to attend “Smart Client development present and future” session,&#160; will take part in Yad leBanim [...]<p/>]]></description>
			<content:encoded><![CDATA[<p>Are you in Israel <strong>11-February</strong> evening? Are you smart client developer and think, like me, that “cloud thingy” is just like Playboy girl, whom you never know what surprises might be waiting for you underneath? If so, you are invited to attend <a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?culture=en-US&amp;EventID=1032403028" target="_blank">“Smart Client development present and future” session</a>,&#160; will take part in <strong>Yad leBanim</strong> house in <strong>Ness Ziona </strong>(<a href="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=%D7%94%D7%91%D7%A0%D7%99%D7%9D+9+,+%D7%A0%D7%A1+%D7%A6%D7%99%D7%95%D7%A0%D7%94&amp;sll=37.0625,-95.677068&amp;sspn=52.285401,69.257812&amp;ie=UTF8&amp;z=17&amp;iwloc=addr" target="_blank">9, Habanim str., Ness Ziona</a>).</p>
<p><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="379" alt="image" src="http://khason.net/images/2009/01/image18.png" width="490" border="0" />&#160; <br /><font size="1">© Apple store at iMall in Tampa Bay, FL (by </font><a href="http://www.nickstarr.com/" target="_blank"><font size="1">Nick Starr</font></a><font size="1">)</font></p>
<p>What we’ll speak about? Net 3 hours of smart client development, which includes WPF for infotainment, WPF for Line-Of-Business, WPF for weak netbooks, running Windows 7 Ultimate. DirectX bridge to enhance user experience. Future of .NET framework, including aspects oriented and modular, yet strong type programming, that you can already use today with some tricks, will be explained. We’ll speak with odd devices, by using some build-in core interfaces from next generation device framework. And much-much more.</p>
<p>Everything is possible 11th February evening, even tits, which will be shown during this session. So it <a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032403028" target="_blank">worth to attend</a>. Number of places is limited, so first registered &#8211; first served.</p>
<p>See you there</p>
<p><a href="https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032403028" target="_blank"><strong>Register to attend “Smart client development present and future” &gt;&gt;</strong></a><strong> (</strong><a href="http://www.facebook.com/event.php?eid=62511686010" target="_blank"><strong>RSVP at Facebook</strong></a><strong>)</strong></p>
<p>Did you know, that 11th February is traditional founding date of Japan at 660BC. Also first session of US senate was opened to the public at 1794. While in 1916, Emma Goldman was arrested for lecturing on birth control and at 1953 Soviet Union broke off diplomatic relations with Israel (1964 the same thing was done by the Republic of China with France). It going to be interesting evening <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/action-required-smart-client-development-present-and-future/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Open Source licenses comparison table</title>
		<link>http://khason.net/blog/open-source-licenses-comparison-table/</link>
		<comments>http://khason.net/blog/open-source-licenses-comparison-table/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 16:21:10 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[blogging general]]></category>
		<category><![CDATA[DEV]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[soft]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://khason.net/blog/open-source-licenses-comparison-table/</guid>
		<description><![CDATA[I have a number of projects, released with OS licenses. However, each time I’m about to release new project, I think once again about under what license to release it. So, today I decided to create small comparison table of most popular free licenses to simplify a process of licensing choose you all of us. [...]<p/>]]></description>
			<content:encoded><![CDATA[<p>I have a number of projects, released with OS licenses. However, each time I’m about to release new project, I think once again about under what license to release it. So, today I decided to create small comparison table of most popular free licenses to simplify a process of licensing choose you all of us.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://khason.net/images/2009/01/image17.png" width="500" height="263" />&#160; <br /><font size="1">© <a href="http://flickr.com/photos/dedjo/" target="_blank">Myself</a> <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </font></p>
<table border="1" cellspacing="1" cellpadding="2" width="939">
<tbody>
<tr>
<td valign="top" width="273">License name</td>
<td valign="top" width="126">Can give my name for derived work?</td>
<td valign="top" width="169">Should derived work remains open source?</td>
<td valign="top" width="209">Can change license type for derived work?</td>
<td valign="top" width="154">Can sell derived work?</td>
</tr>
<tr>
<td valign="top" width="272"><a href="http://www.opensource.org/licenses/apache2.0.php" target="_blank">Apache License 2.0</a></td>
<td valign="top" width="129">yes</td>
<td valign="top" width="168">no</td>
<td valign="top" width="209">yes</td>
<td valign="top" width="153">yes</td>
</tr>
<tr>
<td valign="top" width="271"><a href="http://www.opensource.org/licenses/cddl1.php" target="_blank">Common Development and Distribution License (CDDL)</a></td>
<td valign="top" width="132">yes</td>
<td valign="top" width="168">no</td>
<td valign="top" width="208">yes to compatible</td>
<td valign="top" width="153">yes</td>
</tr>
<tr>
<td valign="top" width="270"><a href="http://www.opensource.org/licenses/gpl-2.0.php" target="_blank">GNU General Public License 2.0 (GPLv2)</a></td>
<td valign="top" width="134">yes, but should mark changes</td>
<td valign="top" width="168">yes, only if published</td>
<td valign="top" width="208">yes to compatible or by owner agreement</td>
<td valign="top" width="152">yes</td>
</tr>
<tr>
<td valign="top" width="269"><a href="http://www.opensource.org/licenses/lgpl-license.php" target="_blank">GNU Library General Public License (LGPL)</a></td>
<td valign="top" width="136">yes</td>
<td valign="top" width="167">same as in GPL, but can link compiled libraries as-is into non-open source software (please reference for more info)</td>
<td valign="top" width="207">yes for compatible</td>
<td valign="top" width="152">yes</td>
</tr>
<tr>
<td valign="top" width="269"><a href="http://www.opensource.org/licenses/ms-pl.html" target="_blank">Microsoft Public License (Ms-PL)</a></td>
<td valign="top" width="138">yes, but cannot use owner’s trademarks</td>
<td valign="top" width="167">no</td>
<td valign="top" width="207">no</td>
<td valign="top" width="152">yes</td>
</tr>
<tr>
<td valign="top" width="268"><a href="http://www.opensource.org/licenses/ms-rl.html" target="_blank">Microsoft Reciprocal License (Ms-RL)</a></td>
<td valign="top" width="139">yes, same as for Ms-PL</td>
<td valign="top" width="167">yes</td>
<td valign="top" width="207">no</td>
<td valign="top" width="151">yes</td>
</tr>
<tr>
<td valign="top" width="268"><a href="http://www.opensource.org/licenses/mozilla1.1.php" target="_blank">Mozilla Public License 1.1 (MPL)</a></td>
<td valign="top" width="140">yes</td>
<td valign="top" width="167">no</td>
<td valign="top" width="206">no</td>
<td valign="top" width="151">yes</td>
</tr>
<tr>
<td valign="top" width="268"><a href="http://www.opensource.org/licenses/bsd-license.php" target="_blank">BSD License</a></td>
<td valign="top" width="141">yes</td>
<td valign="top" width="167">no</td>
<td valign="top" width="206">yes</td>
<td valign="top" width="151">yes</td>
</tr>
<tr>
<td valign="top" width="267"><a href="http://www.opensource.org/licenses/mit-license.php" target="_blank">MIT License</a></td>
<td valign="top" width="142">yes</td>
<td valign="top" width="167">no</td>
<td valign="top" width="207">yes</td>
<td valign="top" width="153">yes</td>
</tr>
</tbody>
</table>
<p>It’s unnecessary to mark, that all copyrights must retain in original and derived work. Also it’s good manner to notice about original authors of open source software also in derived binary work. So if you’re using <a href="http://khason.net/#stuff" target="_blank">my OSS</a> in any of your work, please mark it <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Please pay attention, that except MIT and MS licenses, derived work cannot use authors’ names and origin for derived software promotions.</p>
<p>Another common question is about <a href="http://creativecommons.org/licenses/by/3.0/" target="_blank">Creative Common attribution</a> under which licensed all content in this blog. It is not really license. In spite of this, you can use this attribution to mark your work. CC is all about copyright of owner attributes in derived works, but not about distribution or restrictions of any kind.</p>
<p>Also neither of OS licenses provide responsibility or any kind of assurance for those, who use this software as a part of derived work or in binary format. </p>
<p>Have a nice day, be good people, release open software to push the industry forward and show the world what you worth. </p>
<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/open-source-licenses-comparison-table/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Read and use FM radio (or any other USB HID device) from C#</title>
		<link>http://khason.net/blog/read-and-use-fm-radio-or-any-other-usb-hid-device-from-c/</link>
		<comments>http://khason.net/blog/read-and-use-fm-radio-or-any-other-usb-hid-device-from-c/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 20:42:18 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DEV]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Work process]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[WPF crossbow]]></category>

		<guid isPermaLink="false">http://khason.net/blog/read-and-use-fm-radio-or-any-other-usb-hid-device-from-c/</guid>
		<description><![CDATA[Last time we spoke about reading and decoding RDS information from FM receivers. Also we already know how to stream sound from DirectSound compatible devices. However, before we can do it, we should be able to “speak” with such devices. So, today we’ll spoke about detection and reading information from Radio USB adapters (actually from [...]
Related posts:<ol>
<li><a href='http://khason.net/dev/video-encoder-and-metadata-reading-by-using-windows-media-foundation/' rel='bookmark' title='Video encoder and metadata reading by using Windows Media Foundation'>Video encoder and metadata reading by using Windows Media Foundation</a></li>
<li><a href='http://khason.net/dev/rsa-private-key-import-from-pem-format-in-c/' rel='bookmark' title='RSA private key import from PEM format in C#'>RSA private key import from PEM format in C#</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Last time <a href="http://khason.net/blog/reading-and-decoding-rds-radio-data-system-in-c/">we spoke about reading and decoding RDS information from FM receivers</a>. Also <a href="http://khason.net/blog/capturing-and-streaming-sound-by-using-directsound-with-c/">we already know how to stream sound from DirectSound compatible devices</a>. However, before we can do it, we should be able to “speak” with such devices. So, today we’ll spoke about detection and reading information from Radio USB adapters (actually from any Human Input Devices). Let’s start.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="USB FM HID" border="0" alt="USB FM HID" src="http://khason.net/images/2008/12/image-460dcf0b.png" width="240" height="211" /> </p>
<p>First, if you want to do it, go and buy such device. The are not a lot of alternatives, but if you’ll seek, you’ll find it very quickly.</p>
<p>So, let’s start. First of all, we’ll use platform invoke to get and set the information. Also, we have to preserve handle of the device from being collected by GC. After we’ll finish using the device, we’ll have to dispose it. Thus it makes sense to inherit from SafeHandle and IDisposable.</p>
<blockquote><p>[SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode = true)]     <br />[SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)]      <br />public class USBDevice : SafeHandleZeroOrMinusOneIsInvalid, IDisposable {</p>
</blockquote>
<p>Next, we’ll set a number of arguments, that will be in use during the device lifetime.</p>
<blockquote><p>public uint ProductID { get; private set; }     <br />public uint VendorID { get; private set; }      <br />public uint VersionNumber { get; private set; }      <br />public string Name { get; private set; }      <br />public string SerialNumber { get; private set; }      <br />public override bool IsInvalid { get { return !isValid; } } </p>
<p>internal ushort FeatureReportLength { get; private set; }     <br />internal ushort[] Registers { get; set; }</p>
</blockquote>
<p>Now, we have to find it. The best way of detection human input devices is by product and vendor IDs. Those values are always unique for certain device type.</p>
<blockquote><p>[SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)]     <br />internal USBDevice(uint pid, uint vid) : base(true) { findDevice(pid, vid); }</p>
</blockquote>
<p>Next step is to find a device. To do this, we have to provide extern interfaces to methods of hid.dll and setupapi.dll. Here all methods we will use in our class</p>
<blockquote><p>[SuppressUnmanagedCodeSecurity()]     <br />internal static class Native {      <br />&#160;&#160; #region methods      <br />&#160;&#160; [DllImport(&quot;hid.dll&quot;, SetLastError = true)]      <br />&#160;&#160; internal static extern void HidD_GetHidGuid(      <br />&#160;&#160;&#160;&#160;&#160; ref Guid lpHidGuid); </p>
<p>&#160;&#160; [DllImport(&quot;hid.dll&quot;, SetLastError = true)]     <br />&#160;&#160; internal static extern bool HidD_GetAttributes(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hDevice,      <br />&#160;&#160;&#160;&#160;&#160; out HIDD_ATTRIBUTES Attributes); </p>
<p>&#160;&#160; [DllImport(&quot;hid.dll&quot;, SetLastError = true)]     <br />&#160;&#160; internal static extern bool HidD_GetPreparsedData(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hDevice,      <br />&#160;&#160;&#160;&#160;&#160; out IntPtr hData); </p>
<p>&#160;&#160; [DllImport(&quot;hid.dll&quot;, SetLastError = true)]     <br />&#160;&#160; internal static extern bool HidD_FreePreparsedData(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hData); </p>
<p>&#160;&#160; [DllImport(&quot;hid.dll&quot;, SetLastError = true)]     <br />&#160;&#160; internal static extern bool HidP_GetCaps(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hData,      <br />&#160;&#160;&#160;&#160;&#160; out HIDP_CAPS capabilities); </p>
<p>&#160;&#160; [DllImport(&quot;hid.dll&quot;, SetLastError = true, CallingConvention = CallingConvention.StdCall)]     <br />&#160;&#160; internal static extern bool HidD_GetFeature(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hDevice,      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hReportBuffer,      <br />&#160;&#160;&#160;&#160;&#160; uint ReportBufferLength); </p>
<p>&#160;&#160; [DllImport(&quot;hid.dll&quot;, SetLastError = true, CallingConvention = CallingConvention.StdCall)]     <br />&#160;&#160; internal static extern bool HidD_SetFeature(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hDevice,      <br />&#160;&#160;&#160;&#160;&#160; IntPtr ReportBuffer,      <br />&#160;&#160;&#160;&#160;&#160; uint ReportBufferLength); </p>
<p>&#160;&#160; [DllImport(&quot;hid.dll&quot;, SetLastError = true, CallingConvention = CallingConvention.StdCall)]     <br />&#160;&#160; internal static extern bool HidD_GetProductString(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hDevice,       <br />&#160;&#160;&#160;&#160;&#160; IntPtr Buffer,       <br />&#160;&#160;&#160;&#160;&#160; uint BufferLength); </p>
<p>&#160;&#160; [DllImport(&quot;hid.dll&quot;, SetLastError = true, CallingConvention = CallingConvention.StdCall)]     <br />&#160;&#160; internal static extern bool HidD_GetSerialNumberString(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hDevice,      <br />&#160;&#160;&#160;&#160;&#160; IntPtr Buffer,      <br />&#160;&#160;&#160;&#160;&#160; uint BufferLength); </p>
<p>&#160;&#160; [DllImport(&quot;setupapi.dll&quot;, SetLastError = true)]     <br />&#160;&#160; internal static extern IntPtr SetupDiGetClassDevs(      <br />&#160;&#160;&#160;&#160;&#160; ref Guid ClassGuid,      <br />&#160;&#160;&#160;&#160;&#160; [MarshalAs(UnmanagedType.LPTStr)] string Enumerator,      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hwndParent,      <br />&#160;&#160;&#160;&#160;&#160; UInt32 Flags); </p>
<p>&#160;&#160; [DllImport(&quot;setupapi.dll&quot;, SetLastError = true)]     <br />&#160;&#160; internal static extern bool SetupDiEnumDeviceInterfaces(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr DeviceInfoSet,      <br />&#160;&#160;&#160;&#160;&#160; int DeviceInfoData,      <br />&#160;&#160;&#160;&#160;&#160; ref&#160; Guid lpHidGuid,      <br />&#160;&#160;&#160;&#160;&#160; uint MemberIndex,      <br />&#160;&#160;&#160;&#160;&#160; ref&#160; SP_DEVICE_INTERFACE_DATA lpDeviceInterfaceData); </p>
<p>&#160;&#160; [DllImport(&quot;setupapi.dll&quot;, SetLastError = true)]     <br />&#160;&#160; internal static extern bool SetupDiGetDeviceInterfaceDetail(      <br />&#160;&#160;&#160;&#160;&#160; IntPtr DeviceInfoSet,      <br />&#160;&#160;&#160;&#160;&#160; ref SP_DEVICE_INTERFACE_DATA lpDeviceInterfaceData,      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hDeviceInterfaceDetailData,      <br />&#160;&#160;&#160;&#160;&#160; uint detailSize,      <br />&#160;&#160;&#160;&#160;&#160; out uint requiredSize,      <br />&#160;&#160;&#160;&#160;&#160; IntPtr hDeviceInfoData); </p>
<p>&#160;&#160; [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]     <br />&#160;&#160; [DllImport(&quot;kernel32.dll&quot;, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]      <br />&#160;&#160; internal static extern IntPtr CreateFile(      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; string lpFileName,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; uint dwDesiredAccess,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; uint dwShareMode,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; IntPtr SecurityAttributes,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; uint dwCreationDisposition,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; uint dwFlagsAndAttributes,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; IntPtr hTemplateFile); </p>
<p>&#160;&#160; [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]     <br />&#160;&#160; [DllImport(&quot;kernel32.dll&quot;, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]      <br />&#160;&#160; internal static extern bool CloseHandle(IntPtr hHandle);</p>
</blockquote>
<p>Also, we will need a number of structures, such as device attributes and capabilities.</p>
<blockquote><p>[StructLayout(LayoutKind.Sequential)]     <br />internal struct SP_DEVICE_INTERFACE_DATA {      <br />&#160;&#160; public int cbSize;      <br />&#160;&#160; public Guid InterfaceClassGuid;      <br />&#160;&#160; public int Flags;      <br />&#160;&#160; public int Reserved;      <br />} </p>
<p>[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]     <br />internal class PSP_DEVICE_INTERFACE_DETAIL_DATA {      <br />&#160;&#160; public int cbSize;      <br />&#160;&#160; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]      <br />&#160;&#160; public string DevicePath;      <br />} </p>
<p>[StructLayout(LayoutKind.Sequential)]     <br />internal struct HIDD_ATTRIBUTES {      <br />&#160;&#160; public int Size; // = sizeof (struct _HIDD_ATTRIBUTES) = 10      <br />&#160;&#160; public UInt16 VendorID;      <br />&#160;&#160; public UInt16 ProductID;      <br />&#160;&#160; public UInt16 VersionNumber;      <br />}      <br />[StructLayout(LayoutKind.Sequential)]      <br />internal struct HIDP_CAPS {      <br />&#160;&#160; public UInt16 Usage;      <br />&#160;&#160; public UInt16 UsagePage;      <br />&#160;&#160; public UInt16 InputReportByteLength;      <br />&#160;&#160; public UInt16 OutputReportByteLength;      <br />&#160;&#160; public UInt16 FeatureReportByteLength;      <br />&#160;&#160; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]      <br />&#160;&#160; public UInt16[] Reserved;      <br />&#160;&#160; public UInt16 NumberLinkCollectionNodes;      <br />&#160;&#160; public UInt16 NumberInputButtonCaps;      <br />&#160;&#160; public UInt16 NumberInputValueCaps;      <br />&#160;&#160; public UInt16 NumberInputDataIndices;      <br />&#160;&#160; public UInt16 NumberOutputButtonCaps;      <br />&#160;&#160; public UInt16 NumberOutputValueCaps;      <br />&#160;&#160; public UInt16 NumberOutputDataIndices;      <br />&#160;&#160; public UInt16 NumberFeatureButtonCaps;      <br />&#160;&#160; public UInt16 NumberFeatureValueCaps;      <br />&#160;&#160; public UInt16 NumberFeatureDataIndices;      <br />}</p>
</blockquote>
<p>And a number of system constants</p>
<blockquote><p>internal const uint DIGCF_PRESENT = 0&#215;00000002;     <br />internal const uint DIGCF_DEVICEINTERFACE = 0&#215;00000010;      <br />internal const uint GENERIC_READ = 0&#215;80000000;      <br />internal const uint GENERIC_WRITE = 0&#215;40000000;      <br />internal const uint FILE_SHARE_READ = 0&#215;00000001;      <br />internal const uint FILE_SHARE_WRITE = 0&#215;00000002;      <br />internal const int OPEN_EXISTING = 3;      <br />internal const int FILE_FLAG_OVERLAPPED = 0&#215;40000000;      <br />internal const uint MAX_USB_DEVICES = 16;</p>
</blockquote>
<p>Now, we are ready to start. So let’s find all devices and get its information</p>
<blockquote><p>Native.HidD_GetHidGuid(ref _hidGuid);     <br />hHidDeviceInfo = Native.SetupDiGetClassDevs(ref _hidGuid, null, IntPtr.Zero, Native.DIGCF_PRESENT | Native.DIGCF_DEVICEINTERFACE);</p>
</blockquote>
<p>Now, if a handle we get is valid, we should search our specific device. For this purpose, we have to read device interface information and then get details info about this device.</p>
<blockquote><p>if (hHidDeviceInfo.ToInt32() &gt; -1) {     <br />&#160;&#160; uint i = 0;      <br />&#160;&#160; while (!isValid &amp;&amp; i &lt; Native.MAX_USB_DEVICES) {      <br />&#160;&#160;&#160;&#160;&#160; var hidDeviceInterfaceData = new Native.SP_DEVICE_INTERFACE_DATA();      <br />&#160;&#160;&#160;&#160;&#160; hidDeviceInterfaceData.cbSize = Marshal.SizeOf(hidDeviceInterfaceData);      <br />&#160;&#160;&#160;&#160;&#160; if (Native.SetupDiEnumDeviceInterfaces(hHidDeviceInfo, 0, ref _hidGuid, i, ref hidDeviceInterfaceData)) {</p>
</blockquote>
<p>Once we have all this and information is valid, let’s detect its capabilities</p>
<blockquote><p>bool detailResult;     <br />uint length, required;      <br />Native.SetupDiGetDeviceInterfaceDetail(hHidDeviceInfo, ref hidDeviceInterfaceData, IntPtr.Zero, 0, out length, IntPtr.Zero);      <br />var hidDeviceInterfaceDetailData = new Native.PSP_DEVICE_INTERFACE_DETAIL_DATA();      <br />hidDeviceInterfaceDetailData.cbSize = 5; //DWORD cbSize (size 4) + Char[0] (size 1) for 32bit only!      <br />var hDeviceInterfaceDetailData = Marshal.AllocHGlobal(Marshal.SizeOf(hidDeviceInterfaceDetailData));      <br />Marshal.StructureToPtr(hidDeviceInterfaceDetailData, hDeviceInterfaceDetailData, true);      <br />detailResult = Native.SetupDiGetDeviceInterfaceDetail(hHidDeviceInfo, ref hidDeviceInterfaceData, hDeviceInterfaceDetailData, length, out required, IntPtr.Zero);      <br />Marshal.PtrToStructure(hDeviceInterfaceDetailData, hidDeviceInterfaceDetailData);      <br />if (detailResult) {</p>
</blockquote>
<p>To do this, we have to create memory file first and then share device attributes by using this file.</p>
<blockquote><p>base.handle = Native.CreateFile(hidDeviceInterfaceDetailData.DevicePath,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Native.GENERIC_READ |      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Native.GENERIC_WRITE,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Native.FILE_SHARE_READ |      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Native.FILE_SHARE_WRITE,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; IntPtr.Zero,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Native.OPEN_EXISTING,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Native.FILE_FLAG_OVERLAPPED,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; IntPtr.Zero);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (base.handle.ToInt32() &gt; -1) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Native.HIDD_ATTRIBUTES hidDeviceAttributes;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (Native.HidD_GetAttributes(base.handle, out hidDeviceAttributes)) {</p>
</blockquote>
<p>All the rest is straight forward. Just compare info retrieved with one we already have. And, of cause, release all resources were used (remember, we’re in win32 api world!)</p>
<blockquote><p>if ((hidDeviceAttributes.VendorID == vid) &amp;&amp; (hidDeviceAttributes.ProductID == pid)) {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; isValid = true;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ProductID = pid;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; VendorID = vid;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; VersionNumber = hidDeviceAttributes.VersionNumber;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; IntPtr buffer = Marshal.AllocHGlobal(126);//max alloc for string;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (Native.HidD_GetProductString(this.handle, buffer, 126)) Name = Marshal.PtrToStringAuto(buffer);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (Native.HidD_GetSerialNumberString(this.handle, buffer, 126)) SerialNumber = Marshal.PtrToStringAuto(buffer);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Marshal.FreeHGlobal(buffer);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var capabilities = new Native.HIDP_CAPS();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; IntPtr hPreparsedData;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (Native.HidD_GetPreparsedData(this.handle, out hPreparsedData)) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (Native.HidP_GetCaps(hPreparsedData, out capabilities)) FeatureReportLength = capabilities.FeatureReportByteLength;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Native.HidD_FreePreparsedData(hPreparsedData);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Native.CloseHandle(base.handle);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Marshal.FreeHGlobal(hDeviceInterfaceDetailData);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; i++; </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</blockquote>
<p>Now we have a handle to our device and can manipulate it. Like this:</p>
<blockquote><p>using (var device = USBRadioDevice.FindDevice(0&#215;0000, 0&#215;1111)) {     <br />…      <br />}</p>
</blockquote>
<p>But we still have to provide methods for such usage. Here there are no very complicated code.</p>
<blockquote><p>public static USBDevice FindDevice(uint pid, uint vid) {     <br />&#160;&#160; var device = new USBDevice(pid,vid);      <br />&#160;&#160; var fillRegisters = device.InitRegisters();      <br />&#160;&#160; if (!device.IsInvalid &amp;&amp; fillRegisters) return device;      <br />&#160;&#160; else throw new ArgumentOutOfRangeException(string.Format(&quot;Human input device {0} was not found.&quot;, pid));      <br />} </p>
<p>public override string ToString() {     <br />&#160;&#160; return string.Format(&quot;{0} (Product:{1:x}, Vendor:{2:x}, Version:{3:x}, S/N:{4})&quot;, Name, ProductID, VendorID, VersionNumber, SerialNumber);      <br />} </p>
<p>[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]     <br />protected override bool ReleaseHandle() {      <br />&#160;&#160; return Native.CloseHandle(base.handle);      <br />} </p>
<p>#region IDisposable Members     <br />public void Dispose() {      <br />&#160;&#160; Dispose(true);      <br />&#160;&#160; GC.SuppressFinalize(this); </p>
<p>}     <br />[SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)]      <br />void IDisposable.Dispose() {      <br />&#160;&#160; if (base.handle != null &amp;&amp; !base.IsInvalid) {      <br />&#160;&#160;&#160;&#160;&#160; // Free the handle      <br />&#160;&#160;&#160;&#160;&#160; base.Dispose();      <br />&#160;&#160; }      <br />} </p>
<p>#endregion</p>
</blockquote>
<p>We done. Have a nice day and be good people.</p>
<p>Related posts:<ol>
<li><a href='http://khason.net/dev/video-encoder-and-metadata-reading-by-using-windows-media-foundation/' rel='bookmark' title='Video encoder and metadata reading by using Windows Media Foundation'>Video encoder and metadata reading by using Windows Media Foundation</a></li>
<li><a href='http://khason.net/dev/rsa-private-key-import-from-pem-format-in-c/' rel='bookmark' title='RSA private key import from PEM format in C#'>RSA private key import from PEM format in C#</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/read-and-use-fm-radio-or-any-other-usb-hid-device-from-c/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

