Update: As Brian pointed out, my original idea did indeed have a concurrency issue. This was somewhat obscured by the signature of the ConcurrentDictionary<TKey, TValue>.AddOrUpdate method, which can lull a lazy thinker (like myself) into believing that everything--the set add as well as the queue push--will somehow happen all at once, a...
I am creating MSI installer via VS 2008. I try to delete the temp folder at the end of the installation. That temp folder is created by my installer to hold some batch files for database creation. It always show other process is access it and doesn't allow my code to delete it. I have called the Close() of that access process. I have put...
I'm trying to override the constructor of a partial class in RIA DomainService shared code as follows.
foo.shared.cs:
public partial class Foo
{
private SomeClass _privatevariable;
public Foo(SomeClass variable)
{
this._privatevariable= variable;
}
}
foo is a generated class based on an Entity Framework Model.
When I b...
Why doesn't Windows Phone 7 fully support the C# specification when the only language available to it is C#? Okay, I can understand the lack of "dynamic" support, but why isn't contra-covariance supported? Why aren't third-party libraries that are familiar to us and that we use in server-desktop projects not compatible with the Phone 7? ...
[Test]
public void A()
{
var d = Dispatcher.CurrentDispatcher;
Action action = () => Console.WriteLine("Dispatcher invoked me!");
var worker = new BackgroundWorker();
worker.DoWork += SomeWork;
//worker.RunWorkerAsync( (Action) delegate { Console.WriteLine("This works!"); } );
...
Ideally I'd like to find a way to do something like:
[MyCustomAttribute()]
public void MyMethod()
{
Debug.Write("B");
}
public MyCustomAttribute : Attribute
{
public void OnBegin()
{
Debug.Write("A");
}
public void OnEnd()
{
Debug.Write("C");
}
}
Which would write:
ABC
When MyMeth...
I've been using C# for a while, and have recently started working on adding parallelism to a side project of mine. So, according to Microsoft, reads and writes to ints and even floats are atomic
I'm sure these atomicity requirements workout just fine on x86 architectures. However, on architectures such as ARM (which may not have hardw...
I have an atom feed on a wordpress blog here: http://blogs.legalview.info/auto-accidents/feed/atom
When I download the text of the file and display it on my site, I get strange charactes like the accented 'A' here:
Recent studies are showing that car accident -related fatalities have declined almost 10% since 2008. The reason for t...
Is there any nice pattern in .Net for ensuring that iDisposable fields owned by an object will get disposed if an exception is thrown during construction, possibly during a field initializer? The only way to surround field initializers in a Try/Catch block is if the block is outside the call to the constructor, which will make it rather...
I'm having issues referring to image files and other XAML files when the files are in a higher level directory then the XAML file from which I am referring to them from. Is there a way to refer to the root of the project directory?
For example I have the following files & directories:
Project Root Folder: \root
Icon in root folder: \r...
I don't want to know how to use TypeMock. I'm just intrigued as to how it manages to mock non-virtual methods and sealed or static classes. I'd like to try to do something similar - for the fun of it.
How are the generated classes apparently able to inherit from sealed classes?
...
I have a bounded blocking queue in an application that was written several years ago. Let's just say that the implementation is less than stellar, but it's worked. However, it has some performance problems. It looks like the .NET 4.0 BlockingCollection<T> is the right replacement, but I need to make sure that it is actually a queue. ...
I created my MSI installer for our C# application via VS 2008. I installed it. It created a shortcut for me on the desktop. I clicked that shortcut, the setup process running again and at the end our application was launched. It was not like this yesterday before I added some custom action to create database. I didn't recreate the shortc...
I want to increase the size of my rectangle by 10 pixels. The following code seems not working. Assume sampleRect is my rectangle. Please let me know.
Rectangle temp = new Rectangle(
sampleRect.X - 10,
sampleRect.Y - 10,
sampleRect.Width + 2*10,
sampleRect.Height + 2*10);
...
I have a C# .NET program running an ETL which connects to a DB2 database. Sometimes this database is down, so I'd like to do a health check at the beginning of the application to see if the database is available, without actually calling any stored procedures or pushing any data. Here's an example of the code I'm using now:
OdbcConnecti...
Hi Everyone
I'm having issues with over-lapping tables using iTextSharp.
I have multiple tables(from gridviews) that I would like to write to pdf using iTextSharp.
I would like to only have a 10px gap between each table (vertical wise), and the height of the tables always differ.
Does anyone have an article I can read to help me ou...
Hi All,
We have a silverlight project that uses RIA services. There is some code that I want to share between that project and a web service. I have to leave the code where it is now, i.e. I cannot share the code.
What I thought would be good is for the web service to call the RIA service. It will be sitting on the same server.
I went...
I'm working on a project that's a .NET extension to a rather large classic ASP project, using a lot of C++ COM objects that have been around in our code base forever. Unfortunately, there's a lot of hack-ish code on the C++ side, and I fear that I'm not experienced enough to work out the problem I've encountered.
In a nutshell, I can i...
try
{
MailMessage m = new MailMessage("[email protected]", "[email protected]", "Situação", "Oi, tudo bem?");
SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
smtp.Credentials = new NetworkCredential("[email protected]", "xxxx");
smtp.EnableSsl = true;
smtp.Send(m);
Console.WriteLine("sucesso");
}
catch (Sm...