|
there is not another solution? since i dont know always wich datatables user is calling and this is a little bit strange query?
string StatSelect = String.Format(ProductName LIKE '%{0}%'" OR ProductName LIKE '%{0}%'" OR etc....., SearchTextBox.Text);
tought for something like: string StatSelect = String.Format('%' LIKE '%{0}%'", SearchTextBox.Text); ?
|
|
|
|
|
sortexp = "Name LIKE '" + SearchFor + "%'";
dv.RowFilter = sortexp;
|
|
|
|
|
Hello ,
I wanted to use alerts in my WPF application. in C#.net for every control we have AccessibleRole property. Is anything similar present in WPF? I can use any control for 'alerts' (not messagebox ), but grid is preferable.
Regards
|
|
|
|
|
WPF uses the newer type of accessibility that's available on MS Platforms (it's called UIAutomation and it supercedes MS Active Accessibility). Basically, WPF supports automation peers, and the type of the control can be retrieved from AutomationElement.ControlTypeProperty . One warning - this is not a trivial thing to get, so I suggest you read up on it a bit.
|
|
|
|
|
HI,
My Scenario is:
I have two threads in windows application. one performs action on database and second thread collects updated info and displays it on form in parallel (somewhat like progress bar).
on completion of first thread, I close second thread and flow continues further.
My Issue is:
Whenever I close application in between process(by clicking [X] on top right or Alt+f4 etc.), threads and process both should get terminated but actually my application still remains there in Task Mgr process list and threads continue their execution.
Please let me know how to terminate threads and process explicitly. I made RnD on google and applied some of work-around but in vain.
With Thanks & Regards
Amit Sk Sharma
|
|
|
|
|
Amit for .NET wrote: Please let me know how to terminate threads and process explicitly.
Thread.Abort [^]
Although it'd be neater to signal the thread that your app is exiting and have the thread exit normally.
Amit for .NET wrote: I made RnD on google and applied some of work-around but in vain.
Some things can't be patched by copying code; you'll have to reserve some time and dive into the concepts.
I are Troll
|
|
|
|
|
I just took a reference from google, not copied.but yes I think 'm lacking sm whr with concepts so 'm here.
exactly what I m looking for is how to manage the threads and process through code in desktop application when my application terminates unexpectedly.
With Thanks & Regards
Amit Sk Sharma
|
|
|
|
|
The problem will be gone as soon as you've switched to a backgroundworker; those threads get terminated when the proces is terminated. A foreground-thread is rarely used, but if required, you'd signal it and have it save any remaining data and terminate.
I are Troll
|
|
|
|
|
if you set Thread.IsBackground true, the thread will not prevent your app to exit right away when you choose to terminate it.
BTW: ThreadPool threads (and hence also BackgroundWorker threads) always are background threads.
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.
|
|
|
|
|
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!
|
|
|
|