|
I m already using this, when I close application, window is closed but process and thread both continues with their execution.
experimenting with background worker, will respond soon if target achieved.
With Thanks & Regards
Amit Sk Sharma
|
|
|
|
|
Amit for .NET wrote: thread both continues with their execution.
That is impossible, I suggest you check your code thoroughly. Background threads don't keep a process alive, only foreground threads do.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
We developed windows application which is working fine in Windows XP using crystal report 2008 but also working fine in Windows 7 but only report it is not working in Windows 7. If i view report, Load Report Failed is coming but it is working fine in Windows XP. But in one more Windows 7 system report also working fine. But in one system load report failed is coming.
As i said in one windows 7 system report also working there we installed crystal report 2008. But in other system same crystall report 2008 but it is not working and one more thing, in working system .net framework 7 multi-targeting pack installed and it is not installed in other system where report is not working. What is the actual problem i am not able to find out.
Please reply me if anybody knows.
Thanks in advance
modified on Tuesday, March 29, 2011 8:54 AM
|
|
|
|
|
Without knowing what the errors are you're getting, it's impossible to help you.
|
|
|
|
|
Actually I created One items report.If i run the exe and If i click the report, it has to show all the records. It is working fine in windows XP and it is not working in Windows 7, it is giving load report failed.
In windows XP we used Crystal report 2008 and same thing we used in Windows 7 also. In one Windows 7 system report is working and in another Windows 7 system it is not working.
|
|
|
|
|
Well, without seeing the code that you're using to load the report, it's only possible to guess at the cause.
First thing I would do is make sure the Crystal Report runtime is installed on the machine. Then I'd make sure you're using a fully qualified filepath to the report file you're loading.
|
|
|
|
|
Almost all XP is 32 bit, and Windows 7 is very often 64 bit. When your application was not explicitly set to 32 bit, it will run as a 64 bit application on a 64 bit system. But a 64 bit application cannot load a 32 bit assembly. I do not know the architecture of Crystal Reports, but I'd try setting the platform of the application to x86.
|
|
|
|
|
When the initialization of a property takes a lot of time, and the property could be accessed from several threads, we use a lock statement around the initialization code. It looks something like this:
private object _BerniesLock = new object();
private List<Bernie> _Bernies;
public List<Bernie> Bernies
{
get
{
lock (_BerniesLock)
{
if (_Bernies == null)
{
_Bernies = new List<Bernie>();
}
}
return _Bernies;
}
}
But thus we have to create the lock whenever we access the property. Actually, we need it only when we do the initialization (let's assume here that the list would not be changed after initialization). And locks are said to cost some performance.
Consequently, I thought I could optimize that to:
private object _BerniesLock = new object();
private List<Bernie> _Bernies;
public List<Bernie> Bernies
{
get
{
if (_Bernies == null)
{
lock (_BerniesLock)
{
if (_Bernies == null)
{
_Bernies = CreateBernies();
}
}
}
return _Bernies;
}
}
private List<Bernie> CreateBernies()
{
List<Bernie> retVal = new List<Bernie>();
return retVal;
}
When the member variable is not null, I can return it. When it is null, create the lock, check again if it is not null (a different thread may have created the list meanwhile), and if necessary create the list. The list is created in a different function, otherwise the list could exist without having been filled properly, and cause some exceptions when iterating while it is still being filled.
Looking at the code, it looks as if it could work.
But I have some doubts.
What is the state of the member variable _Bernies when the function CreateBernies() is being executed? Is it really still null? I remember the times when I was programming in C++ (VC++ 6), when invalid pointers were a terrible thing to debug: pointers which were not null, but pointed to just somewhere (typically 0xcdcdcdcd). Is the implementation of the .NET framework safe here?
And next, there exists a volatile key word. It is used to prevent caching, when the variable is accessed it is always freshly read from memory. When I look at the situation above, the second time the member variable is checked for null would be a perfect candidate for the use of volatile, i.e.
private volatile List<Bernie> _Bernies;
But volatile costs a lot of performance too, perhaps even more than lock...
In the concrete case I can live well with the standard solution. But having stumbled upon these issues, I am now curious to learn more, and I am looking forward to an interesting discussion.
|
|
|
|
|
replacing lock-test by test-lock-test is a typical pattern to avoid the lock most of the time.
volatile is required to avoid the second test to rely on stale data kept around from the first test.
Bernhard Hiller wrote: But volatile costs a lot of performance
No it does not. All it does is say: go fetch that variable again, don't use a local copy you happen to have around, use the real thing. There is no system call involved, no lock mechanism, nothing. It is just referencing the intended class member.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks a lot for this information. I guess I will use that pattern more often in future.
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Something I've only played around with out of curiosity and never seriously used, so a question really (there could be a good reason it is a bad idea)
Isn't this situation, the deferred creation of _Bernies, what Lazy<T> is for?
private Lazy<List<Bernie>> _bernies = new Lazy<List<Bernie>>(System.Threading.LazyThreadSafetyMode.PublicationOnly);
public List<Bernie> Bernies {
get
{
return _bernies.Value;
}
}
|
|
|
|
|
This is a method to defer initialization however in the op's case he needs to control initialization by more than one object, not just lazily.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Yeah, as I said I am not sure.
BTW, I was thinking the Lazy<T> constructor that has a delegate parameter for initialising the array. I must be wrong, or am completely misreading what the OP was trying to do. Which I thought was to guarantee thread-safety when the property is being accessed during instantiation of the array.
I think I am misreading it all.
Cheers
|
|
|
|
|
That's a new feature of .NET 4. Already its name implies that it was made for me (I am really lazy), hence I should upgrade to .NET 4 soon.
|
|
|
|
|
Smile. Yeah, it may be a lazy way indeed, which is probably why I was sounding hopeful!
|
|
|
|
|
---------------------------
Error
---------------------------
Fatal Execution Engine Error (0x7927f26e)
---------------------------
OK
---------------------------
pls help resolve this error.
Thanks inadvance..
No Defeat Is Final Until You Stop Trying!.......
|
|
|
|
|
This error is normally the result of a corruption of your .NET installation. I'm afraid it means that you are going to have to reinstall .NET. BTW, I found this with a quick Google of the exception you typed in. You could have found the answer quicker than it took you to type your question. Why did you not use Google first?
|
|
|
|
|
I hav googled it already bt nothing resolved my problem.
i hav reinstalled my .net framework still the problem persists.
so i thought of posting here if somebody facing the same issue can help resolve.
No Defeat Is Final Until You Stop Trying!.......
|
|
|
|
|
Are you running multiple versions of .NET on your machine? It could be that the app is targetting a different version of the runtime to the one you think it is. A way to test this is to create a virtual machine with an installation of the framework that you think it's targetting, and attempt to run the application in this VM. Then, if it still fails, create a simple console application that definitely targets that version. If you the console app works, then you pretty much know that either your whole application is hosed, or it's a different version of the framework that it should be running.
One thing you could do, is try to load your assembly from a different .NET application using the Assembly load methods and see if it throws a BadImageFormatException which can occur if your application is either not a .NET assembly, or is internally corrupted.
Beyond that, the corruption could be because you are relying on a component that uses a different version of the .NET framework to the one you reloaded, and that framework is corrupt.
|
|
|
|
|
thank you for the valuable suggetions..
i'll check all the cases
No Defeat Is Final Until You Stop Trying!.......
|
|
|
|
|
Good luck. I hate exceptions like this.
|
|
|
|
|
I think Microsoft .Net files were screwed up. failed to use Control Panel to get rid of them. Able to download Microsoft .Net V2.0 for install, but just did a repair .
|
|
|
|
|
Could the subject be any more clear?
Especially when writing your own Generic classes.
I kind of know how they work (little experience).
For example, would the following be acceptable?
Public Interface ISomething(As T)
Function Something As T
End Interface
Public Class SomethingElse(As T)
Public Property SomeStuff As T
End Class
Or is that just not best practice?
I know some of the benefits, like no (un)boxing of Objects (thus fater performance and less chance on wrong casts?).
What are the drawbacks?
Edit:
And of course when to (not) use Generics
It's an OO world.
|
|
|
|
|
Generics can be very useful. I believe the complier actually creates the classes based on the type so you end up with multiple versions of the same class - one for each (or each combination of types if using <T, V> etc). This I suppose could lead to bloat if there are lots of different T s in your code, but there would have to be a lot! If you used object then there would only ever be one type of the class.
I'm not fond of auto properties as there is no oportunity for validation in the setter or event raising.
|
|
|
|