|
I know the Invoke procedure, but we can use Invoke when we have a Form!(Form.Invoke())
my threads are implemented in Program class where i Run my application(and there is no this.Invoke method!):
look here: my Form1 obj(f) during its lifetime will raise some events! i want to handle those events from thread2 and do the jobs in thread2!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Server
{
static class Program
{
static System.Threading.Thread thread2 = null;
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Form1 f = new Form1();
thread2 = new System.Threading.Thread(new System.Threading.ThreadStart(worker));
thread2.IsBackground = true;
thread2.ApartmentState = System.Threading.ApartmentState.STA;
thread2.Start();
try
{
f.job1 += new EventHandler(Job1);
f.job2 += new EventHandler(Job2;
f.job3 += new EventHandler(Job3);
Application.Run(f);
}
catch(Exception r)
{
}
}
static void worker()
{
}
}
|
|
|
|
|
Someone has asked a similar question to yours, here[^], perhaps you can get some ideas from there.
There are also several articles here on CodeProject. Use the Search articles box, at the top of the page, and search for threaded splash screen, or similar.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Does the worker() method create a Form? What do the event handlers for Job1, Job2 and Job3 do - update the form created inside worker?
If you're getting a CrossThread exception, it means you're updating *some* UI control from the wrong thread - it doesn't necessary have to be the main Form.
|
|
|
|
|
In general speaking, i want to handle events that raise by thread1 and process them with thread2, that's all!
|
|
|
|
|
My first thought is a synchronized queue of delegates (which represent fired events) but that would be painful and probably overkill.. It's just a thought, not advice.
|
|
|
|
|
Hi.
My solution (working in VS 2008) has a C# console app, and a C# web service. The service has an entity data model. It has numerous stored procedures. For one of the stored procs, which just returns data (SELECT blah blah FROM...), I added a function import called "Iservice." I saved all, then in my console app, updated the service reference to my C# service. Now, in my console app, I am trying to do the following:
myEnts db = new myEnts(new Uri("http://localhost:3811/isr.svc"));
foreach(st_service sr in db.Iservice(false))
Console.WriteLine("Number#: {0} " + sr.num);
This doesn't work. "Iservice" is the name of the function import I created and I can see it in the object browser, but when I look at the service reference, I can't see it in the object browser. The compiler doesn't like "db.Iservice(false)" and the message is that myEnts from the service reference does not containt a definition for "Iservice."
So when I am in the service project, and look at the object browser, I can see Iservice - however when I look at the service reference in the object browser, from the console project, I do not see Iservice. How come this happens? How can I fix this? I tried saving, closing, and reloading MSVS2008, I tried updating the service reference multiple times. I googled for examples of calling stored procs in the EDM, and tried different ways of calling it as shown here:
http://blogs.microsoft.co.il/blogs/gilf/archive/2009/03/13/mapping-stored-procedure-results-to-a-custom-entity-in-entity-framework.aspx[^]
http://blogs.msdn.com/bags/archive/2009/03/13/entity-framework-modeling-select-stored-procedures.aspx[^]
http://blogs.msdn.com/adonet/archive/2007/09/14/how-to-map-stored-procedures-using-the-ado-net-entity-framework.aspx[^]
I'd appreciate any help.
PS -- The stored proc that I created a function import for takes in a BIT as a parameter. When in my service project, and looking at the object browser, it shows Iservice as "Iservice(bool?)" which is strange to me. Why the question mark?
|
|
|
|
|
dfn wrote: "Iservice(bool?)" which is strange to me. Why the question mark?
I think that it is treating it as nullable.
Apart from that, I am lost.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: I am lost
Have a break. You probably have just exhausted your brain cell with a though FLP problem.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
lol. My brain could use a break from it too you know, or a hint.
|
|
|
|
|
dfn wrote: Iservice(bool?)
? is appended to value types to make them nullable; so bool? is either true, false, or null.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks for the help. At least that ? isn't a mystery now. Nothing glaringly wrong with what I'm doing though? I still can't figure out why I can't call the function import I made for that stored proc...
|
|
|
|
|
I'm dynamically adding custom user controls to another user control which contains various flowlayoutpanels, and my problem is anchoring. I have to resize the flowlayoutpanels to fit the maximum width of the dynamic controls being added, and I edited all those controls to have proper anchoring so they resize while maintaining the UI look and feel desired.
This works great individually for each user control in design mode, but not when they are added to the user control which will contain them all.
All fun, but apparently anchoring to a flowlayoutpanel doesn't work (I have no idea why) and I was hoping someone has a workaround?
I'm already considering shifting to regular panels, but I'm reluctant to do this shift so quickly before inspecting other possible workarounds.
Docking doesn't work, the flowlayoutpanel can be anchored to the main User control and widens / shrinks as desired, but to reiterate the controls contained within the flowlayoutpanel, even with anchoring, do not have the desired behavior.
|
|
|
|
|
To quote from the MSDN Documentation for FlowLayoutPanel
Docking and anchoring behaviors of child controls differ from the behaviors in other container controls. Both docking and anchoring are relative to the largest control in the flow direction. For more information, see How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control.
The link, from above[^]
That is all the help I can give, tried a FLP once and found docking etc. too much for my brain cell to cope with.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Gave you a 5 for the link, but I forgot to mention that I checked it out earlier with no avail to my dilemma.
Thanks though, perhaps a second read will help.
|
|
|
|
|
Hi all
if some one can plz send me program that play song and u can choose the song from a list
i wiil be glad i work whise Microsoft Visual Studio 2008
My e-mail: sagiklan@gmail.com
tnx sagiklan 
|
|
|
|
|
If you just want a light-weight method to play WAV files, then use the System.Media.SoundPlayer class. Otherwise, just embed a Windows Media Player control into your form
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
You can download the source code and compiled project here.[^]
|
|
|
|
|
EliottA wrote: You can download the source code and compiled project here.[^]
And another one from here [^]
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
sagiklan wrote: if some one can plz send me
How about using Windows media player? Nobody here is going top "send" you a program. Maybe you can try www.rentacoder.com to write you a program and you can pay them a fee for doing that.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
I suggest you read the link in my post, it has the answer you need.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Perhaps you should've said 'my sig' instead. When i read this at first I thought you'd gave the answer in a previous code begging thread he made.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
When I've said 'my sig' people have responded that they can't understand my answer, so I was trying something different.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Hi everyone.
I'm given a project on C# to develop an advanced font dialog. Instead of the normal
window font dialog, im suppose to customized it by adding few more function by adding a text box to allow user to type in to test the font,
a code page to see the list of character, and the unicode subrange. Its just like integrating the window character map into the font dialog.
I know i have 2 approach to do this.
1. by calling up the original font dialog and start editing the form.
2. Create a new font dialog
Im targeting no 1 since to create a new one, i would have to link them up all together and have to find a way to get the fonts list in the computer.
Anyway, the big problem i have with choice no. 1 is:
1. I dunno how to call up the Fontdialog
2. Im not sure how to expand the font size to allow more info to be display there.
3. Lastly and i don't know how to call up the code page, unicode or even create a textbox that is linked with the "fontstyle", "font", "size" and etc.
I just hope anyone here can advice on the approach to do or give me a link that might help. Am not that good in C# but this project
is hand picked to me, so i have no choice. I spent the whole day trying to solve and search on google to no avail.
Any input will be helpful.
Thx for reading guys. 
|
|
|
|
|
Number 2 will probably be easier
something like
System.Drawing.FontFamily [] families = new System.Drawing.Text.InstalledFontCollection().Families;
Google a bit, probably easier then you think.
|
|
|
|
|
Try searching for "visual inheritance", there are some articles here that might be helpful.
only two letters away from being an asset
|
|
|
|