|
The JIT compiler might even inline the function calls when calling properties, as most property get/setters don't do much. That'll do away with the function call overhead also.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
One of the C# program managers, Eric Gunnerson[^], has commented that in some cases properties are over-used.
There are only a few times when I don't write properties out, mainly when dealing with structs or classes that are used just as data storage without any methods.
For example, one easy way to implement IEditableObject is to do something like this:
class Foo : IEditableObject
{
private struct FooData
{
public int i;
public string j;
public DateTime t;
public object o;
}
private FooData data;
private FooData old;
public int I
{
get { return data.i; }
set { data.i = value; }
}
public string J
{
get { return data.j; }
set { data.j = value; }
}
void BeginEdit()
{
old = data;
}
void CancelEdit()
{
data = old;
}
void EndEdit()
{
}
}
I believe I do something similar in my IExtenderProvider article where all of the data stored for each object 'extended' is stored in a class with public fields. I know this is the case in the code that inspired the article.
In both cases the type exposing public fields is only intended for the use of one class in a private manner.
James
|
|
|
|
|
Ok, i have a process that launches a worker thread to do stuff. The problem I have is that while the worker bee is doing its thing, the main boss thread is coming along and killing an object that the worker bee is using. So, i am wondering is it possible to "stop" or pause the main thread while the worker bee finishes. I know its almost like a thread timing issue, so i am wondering if anyone has advice of this matter.
Thanks
Sameer
|
|
|
|
|
You can call the Join method of your worker thread to make the main thread wait until the worker thread terminates.
www.troschuetz.de
|
|
|
|
|
Autoupdater application is not able to download the files with extension .config.
Our manifest file contains entries for dll files and .config files. The problem arises when the files list starts with the .config file followed by dlls or only the .config file.
When it tries to download the .config file, it throws an error “The server does not support range header”. This comes when we re-start the client machine and download files for the first time.
The manifest file that we are using is:
---------------------------------------
<manifest manifestid="{311085F7-9320-4318-9A67-9BE32F04E111}" mandatory="False"
="" xmlns="urn:schemas-microsoft-com:PAG:updater-application-block:v2:manifest">
<description>a description for this manifest
<application applicationid="{215E1AD7-9ABA-432f-A952-24BABA556850}">
<entrypoint file="TWSWinUI.exe" parameters="">
<location>..\..\..\Elind.TraderWorkStation\Core\UserInterface\WinUI\Bin\
<files base="http://10.150.15.208/BlockBook_TWS/Version1/">
<file source="TWSWinUI.exe.config">
<activation>
<tasks>
<task name="ApplicationDeployProcessor" type="Microsoft.ApplicationBlocks.Updater.ActivationProcessors.ApplicationDeployProcessor, Microsoft.ApplicationBlocks.Updater.ActivationProcessors">
Downloader configuration in App.config is:
------------------------------------------
<includetypes>
<includetype name="Xml Include Type" type="Microsoft.ApplicationBlocks.Updater.Downloaders.BITSDownloaderProviderData, Microsoft.ApplicationBlocks.Updater.Downloaders">
|
|
|
|
|
i have made an web application with c# and sql server 2000 database
i need realy good tutorial or book to know more about how to load my
application with the database to remote web server thank you to any one will
help
nynostore
|
|
|
|
|
Hello,
I've found in every function I am writing I have lots of debug code and was just wondering if I can somehow shorten it. For example:
<br />
void testFunction()<br />
{<br />
try<br />
{<br />
....<br />
Do something that might cause an exception here<br />
}<br />
catch(mySpecialException e)<br />
{<br />
myLogClass.log(e.message);<br />
myLogClass.dump;
}<br />
}<br />
What I would like is to have some kind of wrapper which I could pass the function name (either by name or as a pointer(delegate?)) to it which would then execute and return.
Example:
<br />
void wrapper(functionToRun())<br />
{<br />
try<br />
{<br />
functionToRun();<br />
}<br />
catch(...)<br />
{<br />
myLogClass.log(message);<br />
}<br />
}<br />
<br />
void test()<br />
{<br />
Console.WriteLine("Hello this is a test!");<br />
}<br />
<br />
void hello()<br />
{<br />
Console.WriteLine("Hello");<br />
}<br />
<br />
static void Main(string[] args)<br />
{<br />
wrapper(test());<br />
wrapper(hello());<br />
}<br />
Any ideas?
Thanks
|
|
|
|
|
If all your functions have the same signature, then it is possible. You can do something like
public class Foo
{
delegate void WrapperDelegate();
void Hello() { Console.WriteLine("Hello"); }
void Test() { Console.WriteLine("Test"); }
public void SomeFunc()
{
executeFunction(new WrapperDelegate(Hello));
executeFunction(new WrapperDelegate(Test));
}
private void executeFunction(WrapperDelegate d)
{
try
{
d();
}
catch(Exception e)
{
}
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks for the suggestion but unfortunately hardly any of my functions have the same signature!
|
|
|
|
|
The solution will work if there only a few signatures. You just need to create one WrapperDelegate for each type and add one executeFunction for each such WrapperDelegate.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I'm trying to construct a delegate manualy, at runtime, from an object refference, and a pointer to a method's runtime handle. However, when i try and compile to code :
<br />
System.Windows.Forms.TreeViewEventHandler thing<br />
= new System.Windows.Forms.TreeViewEventHandler(obj, ip);<br />
It throws an error message saying - "Method Name Expected"
How can I get around this?
regards
Cata
|
|
|
|
|
|
Cheers, got to it about 10 seconds after u posted
|
|
|
|
|
It seemst that VS.net doesn't like me running away on my own with delegates. So i just reflected it.
If anyone is interested - Here is the code (Exception Handling omitted for ease of reading):
<br />
public static object InvokeDelegateViaReflection(Type delegateType, object obj, MethodInfo method)<br />
{<br />
ConstructorInfo ci = delegateType.GetConstructors()[0];<br />
<br />
object[] args = new object[]{@obj, method.MethodHandle.GetFunctionPointer()};<br />
<br />
object result = ci.Invoke(<br />
BindingFlags.Public | BindingFlags.Static | BindingFlags.CreateInstance,<br />
null,args,null); <br />
<br />
return result;<br />
}<br />
Hope that helps someone
Cata
|
|
|
|
|
Cool, I didnt actually suggested that
I was thing along the lines of Delegate.CreateDelegate(Type, Object, String) : Delegate , but you method is perhaps 'stricter'
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
source code for voice chating on LAN using C#
|
|
|
|
|
|
Colin Angus Mackay wrote:
And your question is???
As usual...
Give me "source code for voice chating on LAN using C# "
or maybe
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
|
I have requested Source code or any help or logic for
voice communication over LAN.thanks for help.but i m sorry i cannot understand mentioned website or i cannot get source code.please help me an give more information
THANKX
|
|
|
|
|
Anonymous wrote:
i cannot understand mentioned website or i cannot get source code
Nobody mentioned a web site.
No one was able to help. This could be for a number of reasons.
1. No one here has experience of writing voice chatting programs
2. There are experienced people here, but the answer would be long and complex and most people don't have that much time.
3. Your request is too vague.
Questions that generate good answers are generally very specific and do not ask for a whole system.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Hi
I am using .NET Beta 2 now I have a big problem - all my apps exit after some minute without any comment. If I run them in debug mode, I get this in the output window:
The program '[5704] test.exe: Managed' has exited with code -1073741819 (0xc0000005).
Do you know what the problem could be?
Thanks
/Edit:
I know now that this occours if a remote machine disconnects "unnormally" from the application.
If I, for instance, connect to test.exe with some program and then kill the connecting program... then test.exe will disappear...
|
|
|
|
|
Hi,
actually, it should be Lo...
Try to load a form.
On my pc I get a package load error.
If I try to run it, the beta 2 'stuff' just crashes...
Robert
|
|
|
|
|
Hi,
Heres an example of what i am doing now...
line 01 RECORD 1 ,RECORD 2 ,RECORD 3
line 02 data,data,data
line 03 data, ,data
line 04 data,data,data
line 05 RECORD 4 ,RECORD 5 ,RECORD 6
line 06 data,data,data
line 07 data,data,data
line 08 ,data,
line 09 data, ,data
line 10 RECORD 4 ,RECORD 5 ,RECORD 6
line 11 data,data,data
line 12 data, ,data
line 13 data,data,data
I am iterating through the file line by line, because the data between the blocks of records are inconsistent, i'm using regular expresion to test for the begining of the next record so that i know what data to process. the problem is that the method that is making use of this piece of code is required to return only 1 record at any one time. i have managed to solve the 1 record at a time issue by keeping track of the records that were returned and then following a few other steps.
Because I'm testing for the beginning of the next record, the StreamReader will alwaus pass the point at which I need to be in order to read the next block of records that I need to process. i.e line
I have tried moving the position of the base stream to less than to where/what it currently is by doing the following..
_myFile.BaseStream.Position = _myFile.BaseStream.Position - _previousLineData.Length;
but this doesn't work
In addition, both overloads of the Peek() method of the StreamReader are of no use to me (since they only peek for characters without advancing the StreamReader) and i need to read the whole line to test the RegEx in order to determine whether i have reached the end of a block of records.
as can be seen by the generic sample of the file data above, the data in the file is not well organised and or managed.
any help/hints and advice will be much appreciated..
Thanks a million
Afzal Hassen
|
|
|
|
|
I want to add flash (swf) into my application
for example flash buttons..etc..
How can I do that?
|
|
|
|