|
Once again, your patient reply, is appreciated !
Actually, I don't know C++, and I consider myself only at "journeyman" status with C#, but I was once a guru-level PostScript programmer who ended up (where else), at Adobe.
It's funny: at Adobe the programmers who could really produce, on the application side (PhotoShop, Illustrator, Premiere, etc.) were often hard-core programmers who were self-taught, and the CS graduates who were "ace" at algorithms often turned out to be "dead wood."
But, then, there were "geniuses" like Mark Hamburg who transformed PhotoShop into its "post-Knoll" incarnation: I was once talking to Mark, and the topic of what he majored in college came up: he told me he majored in math because he had already read, and understood, all of Knuth's books in high-school, and felt CS had little to offer him. No boundaries in that man's mind ! He was later awarded the Gordon Moore prize by his Silicon Valley peers for his remarkable accomplishments.
The four-person team that created the Acrobat prototype from "zilch" (I was one), were all new hires from a company Adobe acquired, and none of us had formal CS background But, please, don't blame me for what Acrobat became Our "skunkworks" project, under the direct supervision of John Warnock, was under constant attack by other groups within Adobe who considered us, I guess, as "barbarians at the gates"
But, a key difference I saw in the programmers who were so productive on the application side was that they intimately understood the quirks and features of the hardware/OS combination (Mac or Windows) they worked on. On Windows: they understood COM; on the Mac the understood things like custom window-defs, and its intricate, arcane, convoluted system of interacting system rom calls.
And, the fresh CS graduates often had no clue to inner architecture and hardware of personal PC's. Why should they: back in those days they did their homework on terminals wired up to mainframes, usually DEC.
There are people who have strengths in both algorithms and coding, as well as great depth in specific platforms: I have great respect for them !
What I don't understand is how Google ever got Jon Skeet to jump ship from C# ! Skeet, to me, is the guru's guru in .NET and C#.
cheers, Bill
"Our life is a faint tracing on the surface of mystery, like the idle, curved tunnels of leaf miners on the surface of a leaf. We must somehow take a wider view, look at the whole landscape, really see it, and describe what's going on here. Then we can at least wail the right question into the swaddling band of darkness, or, if it comes to that, choir the proper praise." Annie Dillard
|
|
|
|
|
Well, I don't really put much weight into having a formal CS degree. I have one, but I didn't learn how to program in college. I was self taught before that. I went to college right before the DOT COM bubble, so the school didn't really care about computers at the time. Everything was taught in VAX ADA (!) and there was only a 1 unit C++ course.
I worked with a self taught guy who never went to college, but could freestyle regex off the top of his head and get it perfect and could look at a disassembly of your application and figure out within a day or so how to crash it in various ways (via specially formatted user input type attacks I mean). I would hire him in a second to do security testing, etc. but I would never hire him to write an app because he could really care less about having a tool usable by other people besides himself.
I came to the conclusion a few days ago, that interview styles go through certain phases...
* in the early 2000's, Windows interviews were all about MFC & COM and asking you the stupid questions like "what class would you use for this?", "what class would you use for that?" They essentially expected you to memorize the MFC framework.
* in the early-mid 2000's, all the interviews were hitting heavy on design patterns. Singleton, class factory, etc.
* in the mid to late 2000's, they moved on to asking C# .NET questions and expected you to have a solid understanding of the entire framework
* 2009 - 2011, they wanted you to know C#, Winforms, ASP.NET, asp.net web services, JavaScript, html, etc. They wanted desktop + web hybrid guys
This time around, the trend I'm seeing is that very few places are doing desktop apps, so all the C# jobs are web and expect you to know the 15 to 20 web technologies at the expert level.
If you aren't a web guy, the only other jobs are server, mobile, linux type jobs. Those are all in C++. Since there is no .NET in the C++ world, they are asking these types of data structure questions again. Back when C++ was the main language, there wasn't any libraries like this and you had to invent everything yourself. MFC standardized a lot of the libraries.
Oh, I guess there is STL as well. They want you to know that now too. Lol...
|
|
|
|
|
Hello,
If i my application handles an event in the middle of other code running, does it return to previously running code after the event was handled? if not, how can i do it?
|
|
|
|
|
If you are writing a GUI application, the main GUI thread is event driven and will handle an event and execute all code for that handler before returning to the code that raised the event. If you are writing a multithreaded application, the background thread works independently of the main thread and would not be interrupted unless its listening to events as well.
|
|
|
|
|
AFAICT your suggestion has two major drawbacks, memory-wise:
1. it repeats the leading symbols over and over;
2. for each new chunk of license plates it costs a pointer.
I'd consider an N-tier approach; for N=2 that would be some data structure for the rightmost say 3 symbols, and then a second layer of structure to hold all of those, representing the remaining symbols.
The first one could be a run-length as you described, or a linked list, or switch from one to the other scheme depending on the population.
The second one could be a full array, or maybe a dictionary.
Maybe a 3-tier approach would be optimal: an array for 2 symbols (36^2 elements), pointing to an array for 2 symbols, pointing to an array for 2 symbols, holding a 36-bit bitmask for the last symbol. (Yes it would work better if there were only 32 symbols in the alphabet used).
Note: the "pointers" above don't have to be real pointers, they could be indexes into a huge array, requiring say 4B each rather than 8B.
And the simplest approach that might be good enough would be a Dictionary<string,long> where the key holds the first N-1 symbols, and the value is a bitmask covering the last symbol.
PS: this is what I was going to reply to your vanishing question in Algos
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Lol... saw that forum was dead, so I moved it over here .
|
|
|
|
|
That is exactly how forums die.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Luc Pattyn wrote: That is exactly how forums die. "Not with a ! (bang), but by forum transmigration," T.S. Elliot did not write in "Hollow Men."
"Our life is a faint tracing on the surface of mystery, like the idle, curved tunnels of leaf miners on the surface of a leaf. We must somehow take a wider view, look at the whole landscape, really see it, and describe what's going on here. Then we can at least wail the right question into the swaddling band of darkness, or, if it comes to that, choir the proper praise." Annie Dillard
|
|
|
|
|
1. your threads do whatever you make them do, and will continue to do so.
And events get handled by either the main aka GUI thread, or one of the threadpool threads. See here[^].
2. If you have long winding code that executes on the main thread (e.g. in a button click handler), then other GUI events (and Windows.Forms.Timer tick events, and more) will be stalled. That basically is why long winding operations should NOT be executed by the main thread.
3. If other threads need to access WinForm GUI components (Controls), you need to use Invoke. See here[^].
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Beware of Application.DoEvents() ! Using such a terrible line of code can cause chaos, e.g. a second click on the same button can "overtake" the first click somewhere in the middle of execution.
While you can avoid those calls in your code, you'll never be safe when you have to use ThirdParty (often closed-source) code.
|
|
|
|
|
ok.
can i raise event in a thread (Task) and handle this event in the main thread? so task will keep running when event is handled?
|
|
|
|
|
Not exactly (event handlers are always called in the same thread that called them) but if you're talking about a GUI application you can have event handlers that marshal the call to the UI thread if they're called on a different one:
void MyEventHandler(object sender, EventArgs ea){
if(InvokeRequired) {
BeginInvoke(new EventHandler(MyEventHandler), new object[] { sender, ea });
return;
}
}
Using BeginInvoke (instead of Invoke) causes the call to be asynchronous, i.e. the calling thread continues executing while the event handler runs. This is what you requested, but be aware of synchronisation issues with any form of parallel execution. Because you usually don't care about the result of a delegate call, you can ignore the return value and not bother calling EndInvoke at any point.
|
|
|
|
|
OK.
So what will happen if i call an event that is handled in the main thread (not UI thread)?
|
|
|
|
|
help me please...
I'm working thesis now.. anybody have pseudocode about blind watermarking with Discrete Wavelet Transform in C#..??
TQ b4..
|
|
|
|
|
Did you do a search for this (I had to as I have no idea what you are talking about) as there seems to be some pretty good resources already out there[^] - the first hit convinced me I wanted nothing to do with it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi everyone. I have been working on this for what seems like forever and have gotten nowhere. In addition, I have asked for suggestions from others and haven't had much luck with that or searching online. So I figured i would post here and see if maybe someone might have a suggestion for me.
I have an application that makes use of MappedNetworkDrives as the path to the network resources. This works fine. My problem is that the MappedNetworkDrives are not always reconnecting (And never when connected via VPN). However if you go into My Computer and click on the drive it now connects and shows contents. I am looking for a way that I could refresh these drives programmatically when launching my program (When it's shown more than likely as I presume this will take a minute or so) so that this is easier for the user. Does anyone have any idea how I might do this? I'm using C#.
Thanks Again,
|
|
|
|
|
Are you looking for the WNetUseConnection function?
|
|
|
|
|
As Colin suggested you are storing the wrong path, you need to change it to a UNC path[^].
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks everyone for your responses. I will take a look at that. This is my first networked program like this and as our previous program (Developed by another company) used mapped network drives for this purpose, I thought this was how this was supposed to be done.
I greatly appreciate the suggestions and everything.
|
|
|
|
|
Hello to everybody.
I have a library named "mydll.dll".
In this library there is a routine written in non managed C
extern "C" LMUSB_HANDLE PASCAL EXPORT
InitializeDevice(unsigned short usVID,
unsigned short usPID,
LPGUID lpGUID,
BOOL *pbDriverInstalled)
I have to call this routine in C# language. I use dll import
[DllImport("mydll.dll", EntryPoint = "InitializeDevice",
ExactSpelling = true, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern IntPtr InitializeDevice(ushort usVID,
ushort usPID,
ref System.Guid lpGUID,
ref bool pbDriverInstalled);
When I call InitializeDevice I obtain the error "PInvokeStackImbalance was detected".
If I use CallingConvention.StdCall instead of CallingConvention.Cdecl I don't obtain the error but the returning IntPtr value of the InitializeDevice is always 0 (not correct).
My PC is x86 with OS windows 7. I compile dll as x86.
Can someone help me ? Thankyou in advice
P.S. can you see the thread http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/473/t/45398.aspx[^]
modified 2-Feb-12 8:58am.
|
|
|
|
|
I suspect that it is a mismatch in calling conventions.
Your function is declared as PASCAL (which evaluates to __stdcall) but you are trying to call it as Cdecl, which handles the stack a little differently.
Try changing your DllImport to CallingConvention.StdCall
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
If I use StdCall the function will return me IntPtr(0) both in the case the device is connected or disconnected and it is not correct ...
|
|
|
|
|
Griff is right, using the wrong calling convention is likely to corrupt the stack, so you have to take care of that first.
the return value being zero could have many reasons, most probably the function failed to run properly, maybe one of the input parameters has a bad value, your device isn't present, whatever. What would be the expected failure reporting mode of the callee? Does it return zero and set errno or LastError?
Warning: pointers will take 32 or 64 bits depending on your OS and how you build the app.
FWIW: I wrote a little P/Invoke article here[^].
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
YOU ARE RIGHT !!!!
I have mistaken the GUID !!!
Now it works propery !!
|
|
|
|
|
Hi. I am using a C# page to insert data into a table which consists of many columns...
The first column ID which is incremented automatically.
The second column takes input from the front end and is incremented automatically.
Rest columns take input from front end
I use Stored procedure to insert data in the table.
But somehow I find duplicate entries except for first column in the table.
How is this possible? I mean is there an error in my front end coding or is it an error in Sql-server.
Because I tried it myself and it wont allow to enter duplicate values as my logic is perfect and I am inserting values on button click.
But when I fire a query in Sql, it gives me duplicate entries with different ID's only for some records not for all.
Can anybody please help me with that?
|
|
|
|
|