|
Your service is written incorrectly. It sounds like you started a Timer in the OnStart handler to run the service. The is not a good idea. Normally, services are expected to start a seperate thread that runs code that does the service work.
|
|
|
|
|
Hello Dave. Thank you for the information. I am new to this, and this is the first time I have written a windows service. I have a function that initializes the timer, and I have it set to run in the Onstart handler of the service. I put it in the service so it would start back even if the computer rebooted unexpectedly. How can I modify it to start a separate thread? I am not very familiar with threads yet either.
Thanks again,
Heather
|
|
|
|
|
Hi!
I want to rewrite one of my fameworks from php to c# so i can use them to play with asp.net.
So my question is:
since i have a file for the databasehandler class and one for the date and time class and so on,
i wonder if i could do like in php and have one file that includes or at least gives access to the other classes?
So that when i want to use my framewok i only have to work with one file and not all the 20 different files.
/Arne
|
|
|
|
|
Yep, you can create a single dll that contains all your classes, but you may want to consider splitting them out for maintainability/readability.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
ah, tink you got me wrong there.
i want to have something like this "file three"
this is how my php setup work's
EleanorFramework/(my framework's name)
___Eleanor.php(here i include all my file's in the Classes folder)
___Classes/
______Databasehandler.php
______Textapi.php
______logger.php
______...
so when i want to use my framework in php i include Eleanor.php
and creates the class i want to use.
and i wanna do something like that in my class library.
/Arne
|
|
|
|
|
Yeah you can.
Create seperate class library projects
Eleanor.Databasehandler
Eleanor.Textapi
etc... and reference the output dlls of the sub projects in an Eleanor project.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
If this is for a web site, when you add classes to a .Net web app, it puts them into a special folder (AppData or something like that). You can assign a namespace to each class if you like (but it's not necessary), and then include a using statement so that you can access the class inside that namespace. Personally, I find that a bit clunky.
If you want to be able to share the classes between projects, you can create a separate solution that contains these classes and then simply add a reference to it in any web site from which you might want to use them.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
well PHP is not C# things work differently. So for one you need to be prepared to learn C# if you want to use it.
One .DLL file can contain just 1 class or it can contain many classes. If they are static classes you can use thier methods directly, if they are non-static you can create instances of the classes and use them as desired.
You can reference the DLL as needed in your ASP.Net application
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi,
How can i convert MouseEventArgs to ByteArray?
and how can i serilize a MouseEventArgs ?
Thankyou
YPKI
|
|
|
|
|
ypki wrote: How can i convert MouseEventArgs to ByteArray?
What information are you expecting to have stored in this array?
.... sterilize a mouse
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I guess you want to send MouseEventArgs using Socket. In simple language, MouseEventArgs is class and class cannot be converted to byte array but its variables can.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I am working on a program in C# which is supposed to simulate a very simple browser. The program lets user login on yahoo and allows to compose and send mail (for now). For the last couple of weeks it was working just fine but since yesterday whenever it attempts to send mail the html having the following message (from yahoo) is returned:
Sorry for the inconvenience.
You've stumbled upon an unexpected, temporary problem. Performing your action again in a few moments will likely resolve the problem completely. If not, we suggest you try re-launching Yahoo! Mail.
If the problem persists, feel free to contact Customer Care about Error Code 14.
I have used about three yahoo accounts but in vain. Can't figure out why does this message appear . Please help.
|
|
|
|
|
I suggest asking Yahoo, its their error message. Have you tried just logging on and sending an email via the yahoo site to see if you get the same problem?
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi,
I want to add more than one controls like lable, text box for a single cell to the datagridview control.
Thanks in Advance.
modified on Thursday, March 19, 2009 8:18 AM
|
|
|
|
|
Can you even add one?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I can add one control but i cant add more than one.
my requrement is to add more one control to the single cell and select each control
Tqs for the response
|
|
|
|
|
How do you add one control? As far as im aware the different controls you mention are just different styles of datagridview cells.
In which case the same question could be asked. how do i add 2 textboxes to 1 textbox? answer is you cant
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
its not to add 1 control to another control
add to cell those controls and select each control individually.
when you select single control, need to show some properties.
|
|
|
|
|
I know what you are trying to achieve, but my point is that controls cant be added to datagridview cells. Maybe i am mistaken, that why i ask how you can add one control?
Post come code showing how you have managed to add one control to a datagridview cell then maybe i can help you better with your needs
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi All,
I have very little experience with threading and have been building an object that creates a thread internally (not sure this is even a good design idea). Just as an example I have created this class (with a delegate):
public delegate void ThreadCompleterEventHandler(object sender, ThreadCompleteEventArgs args);
public class ObjectThatCreatesAThread
{
public event ThreadCompleterEventHandler ThreadCompleted;
private Thread t;
public ObservableCollection<string> StringsCollection;
public ObjectThatCreatesAThread()
{
StringsCollection = new ObservableCollection<string>();
}
public void PopulateStringsCollectionOnOtherThread()
{
t = new Thread(delegate()
{
DoWork();
});
t.Name = "Populate StringsCollection Thread";
t.Start();
}
private void DoWork()
{
StringsCollection.Add("String1");
StringsCollection.Add("String2");
StringsCollection.Add("String3");
OnThreadCompleted();
}
private void OnThreadCompleted()
{
ThreadCompleted(this, new ThreadCompleteEventArgs());
}
}
This object is created by a button click on a WPF UI. Like:
private void RunThread_Click(object sender, RoutedEventArgs e)
{
obj = new ObjectThatCreatesAThread();
obj.ThreadCompleted += new ThreadCompleterEventHandler(obj_ThreadCompleted);
obj.PopulateStringsCollectionOnOtherThread();
}
In the eventhandler in the UI I have:
void obj_ThreadCompleted(object sender, ThreadCompleteEventArgs args)
{
StringsListBox.ItemsSource = obj.StringsCollection;
}
Which throws a InvalidOperationException "The calling thread cannot access this object because a different thread owns it.". Which is easily rectified by doing this instead:
void obj_ThreadCompleted(object sender, ThreadCompleteEventArgs args)
{
Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate()
{
StringsListBox.ItemsSource = obj.StringsCollection;
}));
}
My question is why does the DoWork() method running on the spawned thread gain ownership of the StringCollection object that was in fact constructed on the UI thread?
Is there any way to move this collection back to the ownership of the UI thread without the need for the Dispatcher.BeginInvoke()
Am I actually just trying to code around a bad practise?
I would prefer to make this object as user friendly as possible so that even though it is spawning a thread internally at the end of the threads execution the collection is made available to other threads to work with, I guess specifically the UI thread. Is there anything I can set at thread construction time to facilitate this?
Thanks,
|
|
|
|
|
Change the signature for the OnThreadCompleted method and try the following.. I have not tested the code:
private void OnThreadCompleted(object sender, ThreadCompleteEventArgs e)
{
System.ComponentModel.ISynchronizeInvoke sync;
if (ThreadCompleted != null)
{
foreach (Delegate d in this.ThreadCompleted.GetInvocationList())
{
sync = d as System.ComponentModel.ISynchronizeInvoke;
if (sync != null)
{
if (sync.InvokeRequired)
{
ThreadCompleterEventHandler del = new ThreadCompleterEventHandler(OnThreadCompleted);
object[] args ={ sender, e };
sync.BeginInvoke(del, args);
return;
}
}
this.ThreadCompleted(sender, e);
}
}
}
|
|
|
|
|
Wow ... thanks for this ...
I just tried this code and I'm getting a StackOverflowException on:
this.ThreadCompleted.GetInvocationList();
If I put a breakpoint on this line and look at the ThreadCompleted object the _invocationList has a count of 0 even though I know there is at least one subscription to the event ...
|
|
|
|
|
If you email me your solution, i can assist you further.
|
|
|
|
|
Thanks for this offer Fayu, where should I send the solution?
Thanks,
|
|
|
|
|
Check your email. I sent you my e-mail address.
|
|
|
|