|
Giancarlo Trevisan wrote: Let's go to an extreme, there is not enough memory to create an object, proper code would still require a reference check
No, proper coding would require that the out of memory exception is handled.
Giancarlo Trevisan wrote: Give you an example, class MythicalFooCreature can't be instantiated if the temperature is below 32F, in my view the constructor should raise an exception and return a null reference.
You can't do both. Either raise the exception in the constructor, or use a Factory Pattern.
If an exception is thrown to something outside the constructor it no longer matters what the constructor would have returned because the garbage collector will get it before anything else can get a reference to it.
Giancarlo Trevisan wrote: I am alluding at a fundamental behavior that in my view would not be crippling but evidently this is not a general consensus.
It wouldn't be crippling per se, but it would change the semantics. There already exists a semantic equivalent for what you want to do over the responsibility of a basic constructor that you can use (i.e. The Factory Pattern) so why reinvent the wheel.
|
|
|
|
|
Colin Angus Mackay wrote: It wouldn't be crippling per se, but it would change the semantics. There already exists a semantic equivalent for what you want to do over the responsibility of a basic constructor that you can use (i.e. The Factory Pattern) so why reinvent the wheel.
Now, this is an answer!
Visualize then Realize
|
|
|
|
|
Hi,
Is there a way to provide a MS-Word type interface in a C# .NET
application?
Does the Microsoft Office 11.0 object let us do this? Or, is there any
third-party library that can be used for such a feature? Please let me know.
Thank you.
Ravi
|
|
|
|
|
DevExpress have a ribbon bar component if that's any help.
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
Thanks for the citation Ed. I'll check out the component.
-Ravi
|
|
|
|
|
Hi,
Maybe, because of extremally hot sommer my searching skills are reduced
to zero, but i couldnt find any detailed description of windows
services, i would be greatful if You could give me some link... well
i'll describe my problem anyway:
I have to write windows service, which on timer event calls function
from unmanaged dll library to comunicate with some device over tcp
protocol and send informations to database. (This dll loads proxy
server (from another dll) to listen for informations from this device)
All code works fine in console/windows c# application
In Windows service it accidently started to work but under quite
unacceptable circumstances...
Server works correct only when i use in timer event function
MessageBoxA imported from user32.dll (i tried this for debugging
purposes)... Also "allow service to interact with desktop" must be
'ON'. (well, i can always see server in netstat, but service cant get data fom
it)
I have tried to use another function from user32.dll (just to load this dll into memory) but with no results...
Thats what i have observed. Im sorry if i dont know something which i
should, im new in c# .net, and now im in a point in which i dont know
which tutorial should i read next...
I would be thankful for ANY help...
|
|
|
|
|
try anthoer method for period waken,
when timer event handler completed it execution, what's next ?
|
|
|
|
|
Timer event is used for polling. It just checkes if there is data pedning, read it if yes, end ends.
Anyway i have tried another simpler aproach. I thought that mayby its not working because of creating multiple threads. So i have created single worker thred which does all work in infinite loop. Although there is the same problem... It looks like this:
private void WorkerFunction()
{
//I tried this but it changes nothing:
// MyDll.LoadLibrary("user32.dll");
//If i am correct the same is done by pinvoke:
// IntPtr dll = MyDll.LoadLibrary("my.dll");
m_nAppId = MyDll.OpenApp(0);
string Id = "123";
m_nLnkId = MyDll.OpenLink(m_nAppId, encoding.GetBytes(Id), 0);
AddTransaction("OnStart " + m_nAppId.ToString() + ":" + m_nLnkId.ToString());
// start an endless loop; loop will abort only when
// "serviceStarted" flag = false
while (serviceStarted)
{
tick++;
AddTransaction(tick);
StringBuilder buffer = new StringBuilder(256);
int res = MyDll.AutoGetPollData(m_nAppId, m_nLnkId, buffer, 256);
if (res != 0)
{
AddTransaction(buffer.ToString());
MyDll.AutoReleasePollData(m_nAppId, m_nLnkId);
}
if (serviceStarted)
{
Thread.Sleep(new TimeSpan(0, 0, pollingBreak));
}
//and now MessageBox. I can put it enywhere within
//loop and it works...
MyDll.MessageBoxA(0, "asd", "Myservice", 0);
}
AddTransaction() sends data to db. "ticks" are always sent properly but not proper data. I appreciate any suggestions, i have no idea whats going on...
|
|
|
|
|
Does anybody know of any API or SDK which I can use to programatically generate visual studio project files and solution files?
Also is there a way to programatically generate a strongly typed dataset or xml schema by passing in a database name, and table name to some API, SDK or .exe?
thanks
|
|
|
|
|
danielk_ wrote: xml schema by passing in a database name, and table name
If you export the table as an xml file you can then use the SDK tool XSD.exe to generate a schema for it and then it can be used again to generate a dataset from it. I think , based on running xsd.exe in a prompt without any args (displays the help).
danielk_ wrote: programatically generate visual studio project files and solution files?
They're just text files, depends on what your input is but it shouldn't be too difficult to build your own utility for this. If you're really stuck take a look at the Solution Import Wizard (or something with a similar name) in SharpDevelop [^]for some pointers.
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|
|
Hi all,
I am developing the Pocket pc application & i want to synchronize database between PC and Pocket PC. How can i do that? I don't have any idea about that.
I am using Sql server ce as pocket pc database and want to synchronize when Active Sync run. and tell me how to write the conduit for pocket pc bcoz my PC database is not sql server.
Help me plz.
shalabh
-- modified at 7:41 Saturday 22nd July, 2006
|
|
|
|
|
Hi all
I have an Task on Combobox and its style is DropDown
ie
When i move the cursor over combobox,
it should be dropdown and show its contents.
after lot work,i didn,t get up to the mark
plz suggest me.
thanks in advance
Nagraj
|
|
|
|
|
Handle the MouseMove event, when it's fired set the DroppedDown property to true.
May I ask why this is required since, for me it would seriously annoy me
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|
|
Hi Ed.Poore,
I am newly joined in an company.
this is what the task given to me ,by our team leader.
Thanks For Your Response.
G.Nagaraju
|
|
|
|
|
Quick question,
Is it possible to either temporarily disable or even suppress an event from firing?
The problem that I'm am having is when I'm manipulating properties (related to the event) the event is firing and I'm, eventually, receiveing a stack over flow exception...
|
|
|
|
|
One simple approach is to put a local boolean viariable in the event handler, defaulted to false. before processing the event, check the flag, if it is fallse, set it to true and do the event processing the set it back to false. if it is true at the start, just return.
|
|
|
|
|
Rob,
Thank you for you reply. I appreciate it. This is what I ended up doing right after posting this. I'm sorry, I should have mentioned it.
I was hoping for a more elegant solution. But this works, so I will continue to use this. Again, Thank You.
|
|
|
|
|
I want to be able to detect .net framework applications and version needed(1.0,1.1,2.0,3.0) applications,executables,and dlls on a PC. Is this possible?
|
|
|
|
|
|
Hi,
Thanks in advance. I have an application which loads the database tables with five different site codes. In future the number of site codes may increase. For each site code 14 files are sent from another server to our server.
I have to write an application which checks for all the files to arrive and converts it into UTF-8 format and then calls the PL/SQL package and this should run parallely.
So I thought of using Multithreading with one thread for each of the site codes with site code as parameter.
Here is the problem I face. For instance, I have a flag which would be set to "No" if the files are missing and "Yes" if the files exist. In multithreading if I have to preserve the variable I have to block the variable from the other threads using it. Suppose for the site code where files arrival get delayed for 5-6 hrs or for some reason and it's thread blocks the variable then the other threads has to wait for this and this is not what I want. And I have set a lot many flags for in this application. Is Multithreading useful in this scenario? Please let me know your suggestions.
Thanks & Regards,
Das.
|
|
|
|
|
I think you would probably want to create the boolean flag with the <threadstatic()> attribute, so that each thread has its own copy of the flag to work with.
This blog explains the usage of ThreadStatic (it's in C#, but you should get the general idea)
ThreadStatic[^]
Hope this helps.
Keith
|
|
|
|
|
why not create a class to process a single site code, and a manager class that creates an array of instances of the first (sitewatcher) class based on a configuration file entrly (list of the site codes). In ieach sitewatcher class, create volatile booleans to represent the states you are interesed in (make them volatile so that the compiler doesn't optimize their usage in loops, etc. Have your manager class periodically iterate the array of sitewatches, if any is not complete, check for files, if there are any, start a filemover theread on that instance, mark it as busy, then move on to the next. repeat the iteration until all are complete...at the end of the day, if all are complete, move or remove tthe files for each, clear the complete flag for each instance, and start all over.
Using a configuration file to specify the sitewatcher entries in the list will make it easy to add another site, just edit the config file and restart the app.
|
|
|
|
|
Hi:
I am using a multiview inside of a formview. The multiview represents different tabs that I have (5 tabs in total).
The problem I have is when I switch modes of the formview. When I am in the readonly mode and want to edit the record, on clicking the "edit" button, the multiview goes back to the first tab instead of staying on the tab that I was on when I clicked on the button.
Any ideas as to how to make it stay on the current tab?
Thanks.
|
|
|
|
|
Same problem here... Anyone who has the solution ???
|
|
|
|
|
I would like to set a property that takes an argument as the data mapping value of a datagrid column. So in instead of
mappingname = "Name"
I would like to be able to say
mappingname = "fields(name)"
Is this possible, and does anyone know how it could be done? And yes, I promise that I really, honestly have a good reason for wanting to do it
Thanks
Luke
|
|
|
|