RE: DriveInfo.GetDrives() not returning

2010-05-17 Thread Maddin, Peter
Changing my code from originalFileName = String.Empty; using (var csv = new CsvReader(new StreamReader(fileName), true, Delimitor)) { To originalFileName = String.Empty; // open the file. It is expected to be a CSV file wit

Re: How To do something every so often

2010-05-17 Thread David Connors
On 18 May 2010 16:12, mike smith wrote: > On 18 May 2010 14:19, Dylan Tusler > wrote: > > Is >= slower than > by itself? > > Not at all. > > [ ... ] Not all instructions take the same number of clock cycles to execute (which is not to say you're wrong - but the same number of instructions !=

Re: How To do something every so often

2010-05-17 Thread mike smith
On 18 May 2010 16:12, mike smith wrote: > On 18 May 2010 14:19, Dylan Tusler > wrote: >> Is >= slower than > by itself? > > Not at all. > >        if (foo == 1) > 00053EEC  cmp         dword ptr [ebp-54h],2710h > 00053EF3  jne         CTrimAutoDeployModule::main+8Ch (53EFCh) >        { >    

RE: DriveInfo.GetDrives() not returning

2010-05-17 Thread Maddin, Peter
Thanks Silky and Bill I was just going to isolate my code in a small standalone application just prior to reading your missive. I thought their might be some lock in place but I only use this code in one place. The method is static. There is no means to close, shutdown or release anything that

Re: How To do something every so often

2010-05-17 Thread mike smith
On 18 May 2010 14:19, Dylan Tusler wrote: > Is >= slower than > by itself? Not at all. if (foo == 1) 00053EEC cmp dword ptr [ebp-54h],2710h 00053EF3 jne CTrimAutoDeployModule::main+8Ch (53EFCh) { foo=0; 00053EF5 mov dword ptr [ebp-54

Re: DriveInfo.GetDrives() not returning

2010-05-17 Thread silky
On Tue, May 18, 2010 at 1:53 PM, Maddin, Peter wrote: [...] > I am targeting .NET 3.5. Is it a framework problem, driver problem, some > other problem? > > Could it just be the machine I am using? I know its boring but can you reproduce it in a stand-alone app? (not part of your main one?) My

RE: DriveInfo.GetDrives() not returning

2010-05-17 Thread Bill McCarthy
Hi Peter, Don't know if this would help, but rather than using this bit: drive.RootDirectory.ToString().Substring(0,1) Perhaps if you instead iterated Directory.GetLogicalDrives and created the DriveInfo's , eg: private List GetDrivesOfType(DriveType driveType) { if(DrivesW

Re: How To do something every so often

2010-05-17 Thread silky
On Tue, May 18, 2010 at 2:42 PM, David Connors wrote: > On 18 May 2010 14:29, silky wrote: > > > > On Tue, May 18, 2010 at 2:19 PM, Dylan Tusler > > wrote: > > > Is >= slower than > by itself? > > > > At an assembly level it's a very similar instruction. You'd need to do > > some analysis at a l

RE: How To do something every so often

2010-05-17 Thread Bill McCarthy
Hi Meski, |-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of mike smith |Sent: Tuesday, 18 May 2010 12:51 PM |To: ozDotNet |Subject: Re: How To do something every so often | |On 17 May 2010 18:10, Bill McCarthy wrote: |> Inline..

Re: How To do something every so often

2010-05-17 Thread David Connors
On 18 May 2010 14:29, silky wrote: > On Tue, May 18, 2010 at 2:19 PM, Dylan Tusler > wrote: > > Is >= slower than > by itself? > > At an assembly level it's a very similar instruction. You'd need to do > some analysis at a lower level to see if one was really better. > The number of clocks requ

RE: How To do something every so often

2010-05-17 Thread Bill McCarthy
| |This is a very strange comment. | |-- |silky | Uh huh

RE: How To do something every so often

2010-05-17 Thread Bill McCarthy
But why would you code for an exact match if you don't need to? If you are resetting the counter like I suggested, be it by bitwise mask or otherwise, the value should be reset anytime it goes above the designated value. So compare the two: if (counter == value) if (counter > value) Which is

Re: How To do something every so often

2010-05-17 Thread silky
On Tue, May 18, 2010 at 2:19 PM, Dylan Tusler wrote: > Is >= slower than > by itself? At an assembly level it's a very similar instruction. You'd need to do some analysis at a lower level to see if one was really better. David Keans advice is correct. > Dylan. -- silky http://www.programm

RE: How To do something every so often

2010-05-17 Thread David Kean
Dylan: Choose which option you feel most comfortable with. Then if this comparision becomes the slowest part of your program, optimize then. From: ozdotnet-boun...@ozdotnet.com [ozdotnet-boun...@ozdotnet.com] on behalf of silky [michaelsli...@gmail.com] S

RE: DriveInfo.GetDrives() not returning

2010-05-17 Thread Mitch Wheat
Perhaps there is something wrong with your drive? Just successfully tried the code you posted under similar conditions to those you described. Mitch From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Maddin, Peter Sent: Tuesday, 18 May 2010 11:53

RE: How To do something every so often

2010-05-17 Thread Dylan Tusler
Is >= slower than > by itself? Dylan. -Original Message- From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of DotNet Dude Sent: Tuesday, 18 May 2010 2:12 PM To: ozDotNet Subject: Re: How To do something every so often Dylan never said it was multith

Re: How To do something every so often

2010-05-17 Thread silky
On Tue, May 18, 2010 at 2:04 PM, Bill McCarthy wrote: > Possibly, but if you make the code multithreaded you'd have to use an > interlocked increment. Use of a >= or a higher order bit bit-mask means you > don't have to lock as such (if you aren't worried about the exact count) This is a very str

Re: How To do something every so often

2010-05-17 Thread DotNet Dude
Dylan never said it was multithreaded... that would have been a critical piece of info and I'm sure he wouldn't leave it out. He said "very simple little console app" which rules out multithreading. :p On Tue, May 18, 2010 at 2:04 PM, Bill McCarthy wrote: > Possibly, but if you make the code mul

RE: DriveInfo.GetDrives() not returning

2010-05-17 Thread David Kean
I actually own this code - I'll have a look at this in the morning (Seattle time). From: ozdotnet-boun...@ozdotnet.com [ozdotnet-boun...@ozdotnet.com] on behalf of Maddin, Peter [peter.mad...@pathwest.wa.gov.au] Sent: Monday, May 17, 2010 8:53 PM To: ozdotnet@ozdo

RE: How To do something every so often

2010-05-17 Thread Bill McCarthy
Possibly, but if you make the code multithreaded you'd have to use an interlocked increment. Use of a >= or a higher order bit bit-mask means you don't have to lock as such (if you aren't worried about the exact count) |-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotn

DriveInfo.GetDrives() not returning

2010-05-17 Thread Maddin, Peter
I am writing a simple application where users can import data from a file on a CD/DVD. To get a list of ready CD/DVD drives I am using this code /// /// Returns drives of specified type ~ and specified status. /// /// The type of drive one is primarily interested in

Re: How To do something every so often

2010-05-17 Thread Paul Gaske
On Tue, May 18, 2010 at 1:21 PM, DotNet Dude wrote: > Wouldn't this be enough? > > counter+=1; > ... > if (counter == 1) { > ... > counter = 0; > } > Precisely. Bitwise operator use for the sake of bitwise operator use is a bit annoying to read when in maintenance mode, actually. Paul.

RE: How To do something every so often

2010-05-17 Thread Dylan Tusler
That's what I love about this group... -Original Message- From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of DotNet Dude Sent: Tuesday, 18 May 2010 1:21 PM To: ozDotNet Subject: Re: How To do something every so often Wouldn't this be enough? counter

Re: How To do something every so often

2010-05-17 Thread DotNet Dude
Wouldn't this be enough? counter+=1; ... if (counter == 1) { ... counter = 0; } On Mon, May 17, 2010 at 1:30 PM, Dylan Tusler wrote: > I was just writing a very simple little console app to move data from one > file to another (under certain conditions) and I thought it would be > benef

Re: How To do something every so often

2010-05-17 Thread mike smith
On 17 May 2010 18:10, Bill McCarthy wrote: > Inline __asm { } :) Actually, I like the rather geeky inplace printing of - \ | / rather than just dots. It indicates something is happening without filling the screen with dots. -- Meski "Going to Starbucks for coffee is like going to

Re: MVC Unit Testing

2010-05-17 Thread Damian Maclennan
+1 This is what we found on our last project too, we had to mock a whole bunch of stuff to test controllers when most of the work was happening in other places, essentially these tests become redundant tests of your infrastructure. We had a suite of automated UI tests too which gave us good covera

Re: MVC Unit Testing

2010-05-17 Thread Liam McLennan
http://derans.blogspot.com/2010/05/testing-mvc-20-controllers-with.html On Mon, May 17, 2010 at 4:24 PM, Tiang Cheng wrote: > Hi All, > > > > I would like to know what are your favourite MVC unit testing resources > (articles, books, APIs)? > > > > I have a major MVC website that I playing wi

Re: what can cause an OutOfMemoryException error (asp.net)

2010-05-17 Thread mike smith
> On 17 May 2010 12:43, June Xue wrote: >> >> Hi Guys and Girls, >> >> >> >> Is it true that only memory leak can cause OutOfMemoryException errors? >> Is it possible that one application uses too much memory so that >> OutOfMemoryException errors occur in the other applications in the same >> app

RE: MVC Unit Testing

2010-05-17 Thread Tiang Cheng
Thanks guys! -Original Message- From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of DotNet Dude Sent: Monday, 17 May 2010 7:18 PM To: ozDotNet Subject: Re: MVC Unit Testing Hi Tiang, 1. If you haven't already, you should start at: http://www.asp.net/

Re: what can cause an OutOfMemoryException error (asp.net)

2010-05-17 Thread Grant Maw
Yes it is. Very. Apart from the comments already on the thread, I've also seen programmers get themselves into trouble like this when using recursion. If you have a buggy piece of code that keeps recursing, you'll eventually get one of these. On 17 May 2010 12:43, June Xue wrote: > Hi Guys and

Re: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread Winston Pang
Thanks for everyone's feedback and passion around this discussion, I hope I didn't cause a flame war :p Anyways, I had a look at the Trie algorithm, it's along the lines of what I was looking, but I realised it was geared towards a prefix tree, so I dug further and discovered Ukkonen's algorithm,

Re: MVC Unit Testing

2010-05-17 Thread Davy J
When we did the MVC app at the end of last year we tried to implement TDD on the (c) controler part of mvc, but we realised pretty quickly that we wern't actually testing anything. In the end we tested the business logic, the database connections and then used Selenium (firefox plugin) to test the

Re: MVC Unit Testing

2010-05-17 Thread Stephen Liedig
Hi Tiang, Aslo check out The Art of Unit Testing by Roy Osherove ( http://www.manning.com/osherove/) Cheers, Steve On 17 May 2010 12:18, DotNet Dude wrote: > Hi Tiang, > > 1. If you haven't already, you should start at: http://www.asp.net/mvc > 2. The asp.net mvc forum is also very good: > htt

RE: Detecting process type

2010-05-17 Thread Greg Keogh
>But I would HIGHLY avoid to have different behaviour, depending from the environment where your library lives in. I eventually decided that it was not really the decision of the (rather general purpose) library to change its behaviour. I will strive to keep the library blind to how it's being

Re: Detecting process type

2010-05-17 Thread Peter Gfader
Stackoverflow answers the question but source code is not there (yet) http://stackoverflow.com/questions/878598/how-to-detect-net-application-type .peter.gfader. http://blog.gfader.com/ http://twitter.com/peitor On Mon

Re: Detecting process type

2010-05-17 Thread Peter Gfader
One way could be, to get all current loaded assemblies, and check if there is more System.Web.X loaded than System.Windows.Forms.X or some other weird switches... But I would HIGHLY avoid to have different behaviour, depending from the environment where your library lives in. to get started look

Re: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread Michael Minutillo
I agree. Possible but probably not a good idea. If speed is more important than space I'd consider the trie approach because you can get the list of terms that contain an N character substring in N steps. That's true even if you have 1,000,000 x N items in the list. If the list is particularly vol

Re: MVC Unit Testing

2010-05-17 Thread DotNet Dude
Hi Tiang, 1. If you haven't already, you should start at: http://www.asp.net/mvc 2. The asp.net mvc forum is also very good: http://forums.asp.net/1146.aspx 3. Also a good idea to look into mocking (eg. Moq, TypeMock). 4. Plus Scott Gutherie's blog of course: http://weblogs.asp.net/scottgu/ 5. Che

RE: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread Bill McCarthy
Hi Michael, Doing an index for every possible substring would be slow and add a large overhead: it would generally be unsuitable for substring matching. In Visual Studio 2010 intellisense only matches based on starts with OR pascal cased words inside the string; so that does make it more viable fo

RE: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread Bill McCarthy
Hi Tiang, See : http://weblogs.asp.net/scottgu/archive/2009/10/22/vs-2010-code-intellisense- improvements-vs-2010-and-net-4-0-series.aspx |-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of Tiang Cheng |Sent: Monday, 17 May 2010

Detecting process type

2010-05-17 Thread Greg Keogh
Folks, I have a library that is called from WinForms apps and from ASP.NET apps and it has to have slightly different behaviour in each case. What is the simplest and most robust way that the library can determine what sort of process it's in? Greg

RE: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread Tiang Cheng
Using the tree datastructure to implement intellisense. Not as fancy as a Trie, but close enough. http://www.codeproject.com/KB/cs/diy-intellisense.aspx I'm on VS2008, which seems to use a 'startWith' check for the suffix. VS2010 may be different IDK. The other option is to use delegate method

Re: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread silky
On Mon, May 17, 2010 at 7:07 PM, Michael Minutillo wrote: > This is how it works and I'd bet that the IntelliSense index is based on > some kind of trie (or a http://en.wikipedia.org/wiki/Radix_tree) built from > this data. You can still do a "contains" search with a trie but you'd have > to index

Re: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread silky
On Mon, May 17, 2010 at 6:35 PM, Bill McCarthy wrote: [...] Bill, you've certainly taken a pretty strange tact in replying to my comments. I think I'll leave it with you at this point. -- silky http://www.programmingbranch.com/

Re: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread Michael Minutillo
This is how it works and I'd bet that the IntelliSense index is based on some kind of trie (or a http://en.wikipedia.org/wiki/Radix_tree) built from this data. You can still do a "contains" search with a trie but you'd have to index every possible substring (which could become a time/space concern)

RE: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread Bill McCarthy
|-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of silky |Sent: Monday, 17 May 2010 6:26 PM |To: ozDotNet |Subject: Re: Filtering algorithm strategies to mimic intellisense | |On Mon, May 17, 2010 at 6:21 PM, Bill McCarthy |wrote:

Re: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread silky
On Mon, May 17, 2010 at 6:21 PM, Bill McCarthy wrote: > Silky: > I'm really not sure if you are just being argumentative or you failed to > read what the original request was. Winston pretty clearly stated that he > was after : > > " Filtering is filtered based on a contains for each item. So it's

RE: Filtering algorithm strategies to mimic intellisense

2010-05-17 Thread Bill McCarthy
Silky: I'm really not sure if you are just being argumentative or you failed to read what the original request was. Winston pretty clearly stated that he was after : " Filtering is filtered based on a contains for each item. So it's essentially mimicing VS2010's contains for intellisense." In case

Re: How To do something every so often

2010-05-17 Thread silky
On Mon, May 17, 2010 at 6:10 PM, Bill McCarthy wrote: > Inline [...] > |> By resetting you also don't need to worry about integer overflows etc. > | > |This is of arguable value > > > *IN FACT* no it is not of arguable value; you may choose to argue it (no > surprises there), but even a 1st

RE: How To do something every so often

2010-05-17 Thread Bill McCarthy
Inline |-Original Message- |From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet- |boun...@ozdotnet.com] On Behalf Of silky |Sent: Monday, 17 May 2010 5:44 PM |To: ozDotNet |Subject: Re: How To do something every so often | |On Mon, May 17, 2010 at 3:17 PM, Bill McCarthy |wrote: |> I'

Re: How To do something every so often

2010-05-17 Thread silky
On Mon, May 17, 2010 at 3:17 PM, Bill McCarthy wrote: > I'd guess that in a tight loop it would probably be slightly faster to reset > the counter rather than continually get the modulus, eg: > > counter+=1 > > If (counter And &H2000) = &H2000 Then >  ' every 8192 >   counter = 0 > End If > >