|
My problem is not that I'm restarting application when mutex is not owned!!! Besides that can never happens in real...
My problem is that I'm not able to (always) own mutex in the second application launch (restart) after it was properly released in first one!!!
That application is not about restarting all the time!!!! But sometimes, when it happens, it may fail for a reason a cannot understand!
|
|
|
|
|
Zilo(svk) wrote: My problem is that I'm not able to (always) own mutex in the second application launch (restart) after it was properly released in first one!!!
As I stated previously I cannot reproduce that behavior. Not with my code or yours.
|
|
|
|
|
hmm..
I can, at least on computer at work. I run exactly that code and it failed.
Let me try at home...
Edit:
I couldn't reproduce that at home either. That's not funny at all....
|
|
|
|
|
If you can't reliably reproduce the functionality if the code, what does that tell you about the quality of your solution?
|
|
|
|
|
u are killing me...
look
I have relatively simple piece of code, that should work perfectly without any problems. It's not something sophisticated. But then, I find out that it's not working so perfectly without any problems, so I try to find out why it doesn't ??? According to all information about Mutex (I read MSDN in the meanwhile) it should work the way I wrote it. So now my question is why it doesn't ? Possibly I might miss some important piece of information... or I don't know why it doesn't work. Maybe my computer at work just got crazy. Anyway, what does that tell about the quality of my solution? I tired of this all...
zilo
|
|
|
|
|
Guys,
Mutex.Close() (in Disposing sequence)
that's it. That's my missing piece of information.
now, I can RIP )
Looks like that on faster CPU's, GC or some other mechanism took care about it(Releasing mutex completely) always before instantiating new app, what my slower CPU at work didn't manage always.
I'm just curious. Did you know it all the time?
zilo
|
|
|
|
|
Nope. I never looked at your code. I read the first part of this thread, and the last part. I never knew you posted any code.
|
|
|
|
|
Hi all,
I have developed a windows application in C#, which is going to display a report and print itt automatically without intimating the user.
The report is displayed in the web browser control using XSL in a windows forms application. I would like to know how to print the report in the landscape format? The user should not be allowed to set the page options like Portrait/landscape.
Please let me know of how this can be achieved from coding
Thanks in Advance.
Thanks and Regards
Madhu
|
|
|
|
|
Hello,
I have a problem when trying to serialize the components(the components are diffrent and they are represented by an interface from that they are derived) of a list using XmlSerializer in C#. The exception message thrown when this line is executed
"XmlSerializer ser = new XmlSerializer(typeof(ISchedule))"
is "Cannot serialize interface BL.ISchedule".
I want to know if is this thing possible and should I avoid the encountered problem.
Thak you!
Lukas
|
|
|
|
|
Hi!
I don't think this is possible.
Think about it: An interface cannot be instantiated. So the XmlSerializer could somehow serialize the public members that are part of the interface, but it doesn't make much sense because there's no way back. If you only have the information concerning the interface, you cannot create an object from this.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi!
I have thought at what you told me before but I want to serialize some classes that are represented by that interface not the interface. I have this some instances of these classes in a list of interface type elements and I don't know how to serialize every element in list without taking in account its particular type only the type it is derived from. Is this thing possible?
Thank you!
Regards,
Lukas
|
|
|
|
|
When serializing, there is always one root object (which is associated with the root node in the xml). I'm assuming you have an object (say MainClass) that has a collection of sub-objects (say in a property called Items). The Items is a collection of objects that implement an interface (say IMyInterface). Is this correct?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi, Tom!
All what you have supposed is true. Help me,please, if you know the solution for this problem.
Thanks,
Lukas
|
|
|
|
|
If you have a set number of classes, then you can specify these classes that can appear in the Items collection, like so:
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
public class MainClass {
private List<IMyInterface> items = new List<IMyInterface>();
[XmlArrayItem(typeof(MySubClass1))]
[XmlArrayItem(typeof(MySubClass2))]
[XmlArrayItem(typeof(MySubClass3))]
public List<IMyInterface> Items {
get {
return this.items;
}
set {
this.items = value;
}
}
}
If you have a variable number of items, then instead of using XmlArrayItemAttribute, you can specify the class types using this[^] XmlSerializer constructor. Keep in mind that if you use this constructor, that a new assembly (.dll) is created, saved to disk, and loaded into your application's memory every time you call it (see this[^] for more info).
In either case, you will need to know all the class types that will be in the Items property.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi, Tom!
Thanks a lot!
Lukas
|
|
|
|
|
While using this tutorial, ia have problem in the following code
if (Application.OpenForms.Count > 1)
as error occur that 'System.Windows.Forms.Application' does not contain a definition for 'OpenForms'
Can You please solve my problem
Mandeep
Email: cheers_man2003@yahoo.co.in
|
|
|
|
|
Well - it would seem to me that you have three problems:
1. The error tells you that Application doesn't have a definition for OpenForms.
2. I have no idea where this tutorial is.
3. Questions like this should be asked of the author.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete is correct. But, I can tell you that it sounds like you've stumbled acrossed code written for the .NET Framework 2.0 and above, and you're using .NET 1.1 or below. The Application.OpenForms property didn't show up until .NET 2.0.
|
|
|
|
|
hi
Thanks for reply.
I am using .NET 2003 version. if that event is not available in this version , then please solve my problem by giving me other alternative that I can use in its place.
Mandeep
Email: cheers_man2003@yahoo.co.in
|
|
|
|
|
That's not an event. It's a property that exposes a collection.
There is no equivilent in .NET 1.x. Since all you did was say that this particular line gave you a problem, I can't give you an alternative to anything. You haven't described what the goal of using this code it.
If what you're looking for is something that shows you how to up a Splash screen, then all you need to do is Google for "VB.NET .NET 1.1 Splash Screen".
|
|
|
|
|
Forgive the 'generic' formatting, I don't seem to be able to post 'proper' generic code here.
I have a simple class (see below). I need to have a way to have a SINGLE collection of 'GenericDataElement' objects.
Is this possible? Some of the items may be GenericDataElement<<string>> , while others may be GenericDataElement<<int>>.
public class GenericDataElement<<T>> <br />
{<br />
private string name;<br />
private T value;<br />
<br />
<br />
public string Name<br />
{<br />
get { return name; }<br />
}<br />
<br />
public T Value<br />
{<br />
get { return value; }<br />
}<br />
<br />
public GenericDataElement(string name, T value)<br />
{<br />
this.name = name;<br />
this.value = value;<br />
}<br />
<br />
}
|
|
|
|
|
It isn't possible to have a strongly typed generic list that allows 2 different type parameters, but you can do something like that:
public class GenericDataElement
{
}
public class GenericDataElement<T> : GenericDataElement
{
public GenericDataElement(string name, T value)
{
this.name = name;
this.value = value;
}
private string name;
public string Name
{
get { return name; }
}
private T value;
public T Value
{
get { return value; }
}
}
public class Test
{
List<GenericDataElement> list = new List<GenericDataElement>();
public void TestIt()
{
list.Add(new GenericDataElement<string>("string", "value"));
list.Add(new GenericDataElement<int>("int", 1));
foreach (GenericDataElement gde in list)
{
if (gde is GenericDataElement<int>)
Console.WriteLine("int");
else
Console.WriteLine("string");
}
}
}
But you will have an untyped collection, of course.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Hy,
I have the following code put in the protected override OnKeyDown to a RichTextBox:
switch (e.KeyCode)
{
case Keys.Tab:
case Keys.Enter:
{
autocomplete(_defaultColor);
e.Handled = true;
break;
}
}
and the autocomplete method:
private void autocomplete(Color defaultColor)
{
for (int i = 0; i < 1; i++)
{
SendKeys.SendWait("{BACKSPACE}");
}
SendKeys.SendWait("public");
}
1.Run the application and press "p" then press ENTER.
2.Run the application and press "p" then press TAB.
In both cases the effect is different but is the same code for both cases.
Can somebody give me an explication?
-- modified at 8:58 Tuesday 9th October, 2007
|
|
|
|
|
Hi,
unless you set KeyEventArgs.SuppressKeyPress true, there will be a KeyPress event,
which will act differently for ENTER and TAB.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hello Luc,
Luc Pattyn wrote: set KeyEventArgs.SuppressKeyPress true
very interesting!
Do you also know a .Net 1.1 solution for that problem?
All the best,
Martin
|
|
|
|