|
The good man heard that he was supposed to start a thread when some task takes longer. He did that. Nobody told him what to do once he got the thread going.
Good soldiers who obey every order rarely make good thinkers
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
The only reason I can imagine doing something like that is if there is a requirement that GenerateTimeLineImage() execute on a non-UI thread, and yet be synchronized to the UI thread that requests the operation.
There are plenty of the opposite circumstance (requesting a UI operation from a worker thread), but this sounds strange.
Software Zen: delete this;
|
|
|
|
|
Or perhaps to protect the UI thread from Exceptions?
|
|
|
|
|
Or perhaps there is another thread that somehow manages these extra threads (e.g., abort them if they take too long).
|
|
|
|
|
The Thread object is local so I don't think this can be happening.
|
|
|
|
|
That's even worse since it's effectively a really obfuscated empty catch block!
|
|
|
|
|
PIEBALDconsult wrote: Or perhaps to protect the UI thread from Exceptions?
I suspect that would probably be a misunderstanding of exceptions.
If the thread code doesn't catch exceptions then it will terminate the application, thus certainly impacting the UI.
And if it does catch exceptions then just the same as wrapping the method call in a try/catch.
|
|
|
|
|
Call me a nice guy who generally gives people the benefit of the doubt, but this looks like code where someone INTENDED for some operations to occur on separate threads asynchronously, put some of the plumbing in, put a thread.join in for synchronous debugging, and never got back to it.
You are correct in that the code would be more performant without creating the additional thread as they presently are, but the context of the usage is also important in determining your predecessor's intent. If GenerateTimeLineImage() is a void function that is basically a "fire and forget" service call, commenting out m_thread.Join() might increase application performance, and by quite a bit.
I'll tell you that there is no hidden magic, but you haven't provided enough context for me to be as condemning as some other folks here.
|
|
|
|
|
Member 7679313 wrote: Call me a nice guy who generally gives people the benefit of the doubt, but this
looks like code where someone INTENDED for some operations to occur on separate
threads asynchronously, put some of the plumbing in, put a thread.join in for
synchronous debugging, and never got back to it.
Ok, I call you a nice guy He did write that he found this in serveral places in the code, wich makes some kind of accident less likely. I would just take a look at some other projects he worked on and if something like that also appears there, then there is little room left for doubt.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
If GenerateTimeLineImage is managing multiple threads, then the code makes sense. If not, then the coder read something, didn't understand it, but thought it was "cool", without understanding what the method was for.
|
|
|
|
|
If there's version control in place, have a look - it might be that previous versions had some code between .Start() and .Join().
|
|
|
|
|
Hi Friends...
I have AJAX calender control in my application.
But i am not able to select the day before from current date.
Only able to select after the current date.
What can i Do.
Collapse | Copy Code
<asp:Label ID="lblstartdate" Text="Start Date" CssClass="lbl" runat="server"></asp:Label>
<AjaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</AjaxToolkit:ToolkitScriptManager>
<asp:TextBox ID="txtstartdate" CssClass="txtbox" runat="server"></asp:TextBox>
<ajaxtoolkit:calendarextender runat="server" ID="calExtender2"
PopupButtonID="btnDate3" TargetControlID="txtstartdate" Format="MMMM d, yy" />
<asp:ImageButton ID="btnDate3" ImageUrl="~/images/CalendarIcon.jpg" Width="20px"
runat="server" />
modified 23-May-12 1:20am.
|
|
|
|
|
Little confused. why is this in "Hall of shame"?
|
|
|
|
|
Pretty obvious, OP should be ashamed for posting this here
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
How right you are!
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
I think he 'mis-responded'.
---------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
English League Tables - Live
|
|
|
|
|
Rahul Rajat Singh wrote:
Little confused. why is this in "Hall of
shame"? Naerling may be right, but maybe the original OP was ashamed he didn't understand the code and didn't understand the point of this forum.
|
|
|
|
|
Just found this gem in my own code Worst part is that this runs quite often in tight loops in production code, haha.
public class SomeClass()
{
private PropertyInfo _propertyInfo;
public SomeClass(PropertyInfo propertyInfo)
{
_propertyInfo = propertyInfo;
}
public void ProcessStuff(object obj, object value)
{
obj.GetType().GetProperty(_propertyInfo.Name).SetValue(obj, value, null);
}
}
Who can spot the blunder?
|
|
|
|
|
Wow!!!
obj.GetType().GetProperty(_propertyInfo.Name)
LOL
But it might be useful, if you want to set a value on a different type that has a property with same name!! otherwise
|
|
|
|
|
Haha, I guess that might be an unlikely scenario in some weird situation, but not the case here unfortunately lol, just pure sillyness
|
|
|
|
|
If he has several classes with common properties or methods, then why does he not simply use an interface and pass objects that inherit from that interface? Reflection can be very useful at times, but it should not be misused to work around flaws in the class design.
Edit: And yes, that code must fall on its nose with an exception when objects are passed which do not have the property he's looking for. It's also not assured that _propertyInfo has ever been set, so a null reference is also possible.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
Perhaps the classes aren't known at compile time? Or maybe you want to dynamically copy properties of one object to matching properties in another? I have no idea lol, but I'm sure there exists some sort of valid use case for code like that.
|
|
|
|
|
There sure is use for this, if you take a look at what happens when objects are instantiated with XAML or when you do data binding to controls. Some of that code must look similar internally. Below he also wrote that checking for null references was removed to reduce the amount of code. Still, reflection is something that should be used sparingly. Reflection is slow and can kill your program's performance if you rely too much on it.
Wise words from somebody who uses XAML as markup for UI styles and layouts and even to load scene elements for a 3D engine.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
Countered the univote. (I couldn't see why this was downvoted)
public class SysAdmin : Employee
{
public override void DoWork(IWorkItem workItem)
{
if (workItem.User.Type == UserType.NoLearn){
throw new NoIWillNotFixYourComputerException(new Luser(workItem.User));
}else{
base.DoWork(workItem);
}
}
}
|
|
|
|
|
Thanks. Who knows, but probably it was just an accident. When someone really disagrees it would be more interesting to read his reply.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|