.net

overlapping appointments using the entity framework

I am using the asp.net mvc with the Entity Framework. I have a list of appointments with a startedat field, an endedat field and a roomid field (called SpaceConfigurationId) and would like to find the list of appointments that have been double booked for a given room. It is fine to assume that endedat is always after startedat. There ar...

How can I make my application scriptable in C#

I have a desktop application written in C# i'd like to make scriptable on C#/VB. Ideally, the user would open a side pane and write things like /// foreach (var item in myApplication.Items) item.DoSomething(); /// Having syntax highlighting + code completion would be awesome but I could live without it. I would not want to require use...

Optimizing multiple dispatch notification algorithm in C#?

Sorry about the title, I couldn't think of a better way to describe the problem. Basically, I'm trying to implement a collision system in a game. I want to be able to register a "collision handler" that handles any collision of two objects (given in either order) that can be cast to particular types. So if Player : Ship : Entity and Lase...

WCF REST POST XML

Here is a code snippet. Please tell me whats the difference between these two codes and also which content suitable for these code snippets. "application/xml" or "plain/text" [OperationContract] [WebInvoke(Method="POST", UriTemplate="DoSomething")] public XElement DoSomething(XElement body) { ... return new XElement("Result"); }...

How to detect sound from microphone in .net

Hello, I currently have code to create webcam that sits in free space and automajically moves up or down depending on a flag that I set by pressing a key on the keyboard. I want to be able to make it so that if sound is detected on the microphone (above a certain threshold so it doesn't just pick up noise) then the flag gets set to true...

Multi-core processor pegged even when all threads are just sleeping

I'm simulating some threading in a Windows Service, and the Thread.Start routine for each of my threads points directly to the following: Private WithEvents CheckForOrdersTimer As System.Threading.Timer Private Sub timerCheckForContracts_Tick(ByVal stateInfo As Object) ' Ticks every 5 seconds, then spawns threads until we're at our...

How do I do this lamba statement as Linq To Sql?

Hi folks, how can the ThenBy be translated to Linq-To-Sql, please? var movies = _db.Movies.Orderby(c => c.Category).ThenBy(n => n.Name) var movies = from m in _db.Movies orderby m.Category // What's the syntax for ThenBy?! // thenby m.Name select m; When i try to do thenby m.Name...

Is there a clean way to make CanExecute always return true with an attribute?

I think I already know the answer to my question, but I want to put it out there anyway. I have an app with a ton of command handlers, each with special logic in their CanExecute methods to enable the bound Buttons appropriately. Now I'm in a situation where I don't want any of the logic to execute, because execution results in calls t...

.NET DateTime to String

Is there a easy way to convert a DateTime object to a string representation like this '2010-03-03 10:38:48'. I'm not sure what the above format is but it is different from the patterns obtainable via ToLongTimeString() etc. Is this a case for string builder? ...

Question about heap & stack memory usage.

In windows operating system, the stack memory is a thread-specific storage, and the call stack is the logic flow of a series of methods. So each thread has it's own stack area. I want to know how heap memroy area is used? Is it thread-specific? Process-specific? Or in .NET, AppDomian-specific? Or shared between all the user applications ...

Using pthreads in VS .NET 2003

Hi all, I'm having some problems with my program in VS .NET 2003. I initially wrote a module that uses the pthread library to create a number of threads to process something. This runs correctly in VS .NET 2003. Then this module was used by someone else and integrated into another larger program. I'm not sure about the details, but th...

What is a .NET Application Domain?

What is exactly is an Application Domain (AppDomain) and how is it different than a process or thread? ...

How to draw a control, without drawing the control.

I've got a list of UserControl objects; when a menu option is clicked to go to another section of the application it does the following: Set the currently displayed usercontrol to visible Clear the main panel's Controls list New up the requested control (if not already created in the list) Add the new control to the main panels' Contro...

Are physical and programmatic keypresses handled differently by either .NET or the OS

Firstly some background information... I have a C# .NET application that runs on a slate pc i.e. no physical keyboard. We are using the on-screen keyboard built into Windows XP Tablet edition to populate TextBox controls on a form. There is no special key press handling for the form (although other components of the UI do handle key pre...

Can I get Silverlight Navigation framework to clear its cache?

Basically, I'm using "View-first" style of MVVM hookup - meaning that the view instantiates the viewmodel (well, it grabs it from the service locator which uses a unity container to resolve it but whatever). This works pretty well most of the time - the Navigation framework paradigm seems to work best with the view-first approach, as the...

Code Example of multiple .NET AppDomains?

From what-is-a-net-application-domain: You can run several application domains in a single process with the same level of isolation that would exist in separate processes, but without incurring the additional overhead of making cross-process calls or switching between processes. I would like to understand more about how/why one wo...

Need a solution for my project to replace the current .NET Remoting solution

Hello everyone, I have a project with requirements: Clients connect to server through internet (WAN) to get data. Server can notify to clients when server has new data. P/S: Client is a .NET WinForm application. Someone suggest me to use .NET Remoting but it only works well on LAN and it has problem when send event to clients through...

EF pulling out reference primary keys in a 1-M relationship...

Hi guys In a 1-M relationship, in the many side of the relationship I can pull out the Id of the parent item without doing another query using something like the following: this.ParentReference.EntityKey.EntityKeyValues[0].Value But what I am wondering if there a similar way of pulling out the many ID's from the 1 without doing anot...

c# cube / multidimensional dataset

I'm working on a problem where i need to process multi dimensional data in memory using C#. My requirement resemble OLAP cubes but are not as complex. for example i don't need calculations or aggregation or stuff like that. I basically would like to reference data using multidimensional keys. for example: var key = new Key(); key["Dim1...

Can I return a StreamReader from a method ?

Can I return a StreamReader from a method ? ...