|
Heath Stewart wrote:
I recommend reading Managed DirectX 9 Kick Start : Graphics and Game Programming[^].
I have it. I assume the rest of the book is better, the bit on audio video playback is 3 pages which glosses over the API, tells me that Microsoft does not regard it as a full implimentation, and it's not going to be updated. It doesn't cover any of the bugs in the API, I presume the author has never actually used this part of DirectX9, and felt they needed to cover it, so they skimmed the docs.
I'm writing an article on all the ways that the AudioVideoPlayback namespace fails to perform as expected, and a wrapper class that will make it a little bit close to usable. I've built an entire project around DX9, and I'm kind of wishing I hadn't.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Steven Campbell wrote:
The programmer can then fix it by changing it to if (null == email).
Ok, but how can null be "equal to" anything? This has got to be a concept I'm not able to fathom or I am just unfamiliar with it. And, for now, it just seem logical.
Best,
Jerry
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
Any reference object - like email (presumably a string, which is a reference type) - is null if it doesn't reference an object. So, it's "value" is null.
string email = null;
null == email;
email = "you@codeproject.com";
null == email;
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
if 2+2 = 4, then 4 = 2+2. The concept is the same. The two values are checked for equality, that the constant value is on the left makes no difference to the compiler, and in C++ was a good was to avoid a bug that can be a nightmare to find. I know, I still sometimes write code like this, a habit I formed in my C++ days.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Ok, thanks Heath and Christian. I think I understand what's going on with that now.
Best,
while(null==jerry)
{
null++;
return;
}
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
To expand on what Steven said, the two are the same because it's a simple comparison. The IL generated from about would be:
ldnull
ldfld email
beq Equal
Equal:
It doesn't matter if you load null or the field (or variable, whichever) first, you're still comparing the value of two objects.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for the answers all. Would this also hold true for the is-equal-to '==' also?
Best,
Jerry
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
OMG! I just woke up and realized what a stupid question that was.
That's what I get for watching the grandchildren and coding at the same time...
Best,
Jerry
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
In C++, it's possible to write:
if (x = 0)
when you mean to write
if (x == 0)
Because of that, some developers invert the order of what they write, as:
if (0 = x)
is illegal, while
if (0 == x)
is legal.
This is not a problem in C#, where if (x = 0) is prohibited.
|
|
|
|
|
Hi
I need a logging framework that let me log asynchronously.
Do you have any suggestion ?
I tried to figure out if log4net does all the logging asynchronously. Does it depend on a specific Appender or all logging is done asynchronously ?
I did a test in which I log 1500 time the same string.
- Log4net with FileAppender is doing it in approx. between 100 and 200 miliseconds;
- Log4net with BufferingForwardingAppender combine with FileAppender is doing it in approx. 2000 miliseconds;
- System.IO does it in approx. 10 miliseconds.
I also tried with EIF using my own EventSink sending all request in a MSMQ queue but using EIF is not as easy to deploy as log4net so...
Any suggestion would be appreciate
|
|
|
|
|
The EIF offers more than just logging using the EIF.
What you're logging to, however, greatly matters unless you're queuing requests in order and flushing them to disk or some other sequential data store.
Note that a simple solution is to define a delgate on the logging method and execute that asynchronously. The backing store matters, however, because doing things this way with a non-thread-safe backing store could cause major problems.
For example:
internal delegate void Log(string message, string category);
Log log = new Log(Trace.WriteLine);
log.BeginInvoke(message, category, null, null); It's an overly simplified example, but hopefully gives you the idea.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Log4Net looks suspiciously like Log4J. Easy to use; but a hog and will slow your program down. In Log4J there are asynchronous appenders, look for the same in Log4Net. You should see some increase in speed; but I wouldn't expect any logging framework to be faster or even as fast as System.IO.
Daniel
|
|
|
|
|
Thanks for your reply Daniel
I have a couple of question regarding what you just said:
1- Can you tell what are the appender that you know is asynchronous (in Log4J at least)
2- Why would you expect System.IO to be faster ? I understand that there is a cost (overhead) to use this kind of framework but if the appender is sending message (logging event) to a structure that it is store in memory, I expect it to be faster than an IO on disk. Am I wrong Daniel.
If I recall my first post, this is exactly what I did using EIF and a specific EventSink (appender). My EventSynk only take the logging event and put it on an MSMQ and return very fast (but telling that remind me that I did not save the metrics for that one, so how fast it realy is... I'll tell you)
Anyway, Thank you to both of you who reply to this post.
I can't believe that in 2004 I'm still worry about logging
Thanks again
Michel
|
|
|
|
|
1. In Log4J you can use something called AsyncAppender. It takes references to already instantiated Appenders and uses them to write asynchronously.
2. Your are not wrong about writing to memory being faster than writing to disk.
But, if your ultimate goal is to have another layer of abstraction manage logging to disk for you faster than using System.IO you probably won't find anything that can. It won't be faster because that extra layer of abstraction will necessarily add some time to processing your logging plus writing the information to disk later.
Daniel
|
|
|
|
|
Hi there,
I'm facing the following problem: I'm writing test cases (using NUnit) for my classes and I have to test for example if properties will throw an Exception when there is an attempt to assign invalid values.
Say I have a Car class with a Speed Property I want it to throw an Exception if the user attempts to assign a value greater then 90.
My test code looks somewhat like this:
Car c = new Car();
bool bFailed = false;
try { c.Speed = 200; }
catch { bFailed = true; }
Assert.IsTrue(bFailed, "Property Speed accepts incorrect values");
When you have a ton of TestCases to write and a lot of Properties to test, this becomes quite cumbersome.
My question is, can this code be somewhat improved? Is there a more generic approach?
Thanks in advance.
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
try it like this...
Car c = new Car();
try {
c.Speed = 200;
Assert.Fail("Property Speed accepts incorrect values");
}
catch ArgumentException
{ }
Be sure to specify the type of the exception (not just Exception ).
my blog
|
|
|
|
|
Steven's answer is good, but this should be better:
[ExpectedException(typeof(IncorrectSpeed))]
public void TestSpeed()
{
Car c = new Car();
c.Speed = 200;
}
NUnit will allow you to tell the test exactly what exception should be thrown by the individual test as an attribute to the test method. The framework will pick up if the exception wasn't thrown and fail the test.
Of course if you want to make it more fine grained than that, say if you are expecting a SqlException with a specific error Number then Steven's code will allow you to pick up on that.*
* However, there is a newer version of NUnit that I've not used yet and it may have that feature already.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
|
I have a program that uses Acrobat Control for ActiveX. However, when a 'bad' pdf gets opened, Acrobat control throws an alert box saying the file is bad and cannot be opened. I want to be able to intercept this to 1) recognize that it happened, 2) prevent the user having to know and click the box, 3) automatically dismiss it.
Is this possible?
|
|
|
|
|
Have you tried monitoring the Windows messages for the control? If you listen for a particular message from the message pump, I'm sure you could intercept it and not pass it on to the Adobe control. Look at the Spy++ tool installed with Visual Studio and monitor the control for the message. Once you know what you're looking for, go back and setup a message hook to intercept it.
I'd bet Heath has a better solution (or might correct me that something posted above won't work) but hey it's a suggestion anyways.
Judah Himango
|
|
|
|
|
Thank You..
Could I send You my input file, so You can see if this code is OK??
|
|
|
|
|
I have two treeviews in a windows application.(leftside and right side)
and there are some nodes in these two treeviews.I want to drag a node from the left treeview to another node in the right treeview.
When the user drag- drop it,a line will be drawed between these two nodes.How can I do this?Could you help me pls?
|
|
|
|
|
One approach is that you handle the graphics drawing yourself.
Another approach is to use controls that specifically handle alot of this for you (such as Northwoods Go.NET controls).
This signature left intentionally blank
|
|
|
|
|
I am trying to read one text file, and create an Array.. Dos someone knews what am I doing wrong??
Can someone correct my code a little bit?
private void panel13_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
ArrayList nodes = new ArrayList();
FileStream file = new FileStream("C:\\NeckingRa\\Temp\\cut.dat", FileMode.Open,FileAccess.Read);
StreamReader sr = File.OpenText("C:\\NeckingRa\\Temp\\cut.dat");
String line;
while ((line=sr.ReadLine())!=null)
{
string s = sr.ReadToEnd();
string[] values = line.Split(' ');
}
sr.Close();
file.Close();
}
|
|
|
|
|
I would make the code look like this:
private void panel13_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
ArrayList nodes = new ArrayList();
StreamReader sr = File.OpenText("C:\\NeckingRa\\Temp\\cut.dat");
String line;
while ((line=sr.ReadLine())!=null)
{
string[] values = line.Split(' ');
nodes.AddRange(values);
}
sr.Close();
} The file variable is not needed and inside of the while look you were reading to the end of the file. Also you had never added the data in values to the nodes variable. I also like using @"c:\NeckingRa\Temp\cut.dat" in C# instead of the normal \\ that we all had to use in C++.
Steve Maier, MCSD MCAD
|
|
|
|