Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Friday, December 19, 2008

Exaustion...

So... i just delivered my assignment... i lost 3 weeks to nothing i guess... is just like a huge amount of code that does a lot of stuff in background, but it does little to be shown to user, so my guess is that i'll have a negative grade or something - teachers usually only look to the interface - go figure... Oh! And teacher requested us to do an webpage to show the work we have done... yeah... he can go to a certain place i know if he thinks we have time to do it.... Well, even if teacher allow to proceed the development in case of negative grade i won't do it, cos i simple have no time: i have to finish another work 'till 10th january (this includes a report and quite some code) and to study to finals (2 classes), not to forget my thesis (that is barelly started), so.... i'll just forget the pratical side of this class, and just study for the finals and do the other work. Yeah.. while unlikely, i'm angry and exausted both physically and mentally... so sorry if my english is not the best .... and sorry for rant about this ... but is better than yell it out loud.... That's all.... i'll just take some - very long - vacations over .NET and C#... now ... i only look to VHDL, C and javascript - they are like my puppies x3, VHDL to have stuff done in hardware, C to do just the stuff i like for most of the stuff, and JS to prototype algorithms or just mess around with browsers... >__>'' good old times.... Damn! I can't even draw now... my tablet is dead and i don't think i'll get a new one so soon.... *sigh* sorry again for the rant... bare with me while i yell at my problems ...

Thursday, December 11, 2008

C# a quanto obrigas...

Sim, claro ... após 600 linhas de codigo para fazer um servidor não há muito que possa estar mal além de uns typos ... certo? .... errado... estaria certo se estivesse a falar de C .... o velhinho C .... mas com o C# aquilo que parecia estar certo pode estar errado ... muito errado... (e de notar que este problema aqui descrito nem foi o pior ... apenas o mais simples de entender). Vejamos como exemplo o seguinte pedaço de codigo: foreach (ClientInfo client in clientList) { if (clientSocket == client.socket) { client.state = ClientInfo.State.READY; } if (client.state == ClientInfo.State.READY) { msgToSend.current++; } } onde clientList é um ArrayList da struct ClientInfo (podia ser um List mas havia problemas semelhantes, mesmo tentando com clientList[index].state).... e onde está o problema? simples, dentro de um foreach podem apenas ler .... yep .... aprendi isso da pior forma.... ou seja, após ter finalizado toda a implementação e testado tudo o resto ... eu definitivamente não me dou bem com OO... Parece que não fui o unico (mais detalhado)... >.< ... bem problema resolvido ... struct pra class ... hora de implementar o cliente ... (definitivamente não vou acabar isto a horas)

Wednesday, December 10, 2008

.NET Framework

While the development of the application for CM classes has stalled due to extreme complexity, i did not stop searching solutions to simplify the application (i don't think i'll finnish the application on time anyway). Regarding network comunication using .NET Framework i found two very nice samples that may provide some help, i share my findings here with you. I hope to post my own solution in the future (or just failing epically as i usually do in high-level languages). Samples are both in C#. Links: A Chat Application Using Asynchronous TCP Sockets A Chat Application Using Asynchronous UDP sockets

Sunday, December 7, 2008

DataSet.WriteXml

Let's talk about .NET Framework (Compact Framework to be more specific) .... again... After spent several hours trying to put my XML file control class to work properly i finnally had some success. When i saw the methods WriteXml and ReadXml for DataSet object i said to myself: "Zeca take a note here... this is pretty usefull!"... only for after a few minutes of coding bash to find out that it didn't quite work like i wanted... things is quite simple to be explained, at least the problem, i check if file exists (Sistem.IO.File.Exists(filepath) - or similar), if not, create a new one with default data on it, then return the data, if file exists, use ReadXML on DataSet and get the data... well ... this works pretty well, ok, now i loaded data into some forms (a settings form) then modify some and exit the form to main menu, when i exit i store the changes on DataSet, and do a WriteXml at the end, simple right? Well it works .... until you do the drill a second time.... it reads correctly, it calls WriteXml at exit, it seems to save the changes .... but it doesn't! Now my solution: Don't use the same DataSet! Create a new one, and yes i tried commitChanges methods before trying this solution... in the end this was the only thing that work. I don't know why this happens, anyway it could be a file open mode problem - when reading the information the file is openned in read mode, and later when writing on it, DataSet.WriteXML uses the same file handler to do the job... failing silently... If anyone had the same problem or know what i was/am doing wrong please fell free to comment it out. Thanks in advance. PS: I really start to hate ALL object oriented languages - not all object-able languages

Saturday, December 6, 2008

.NET Compact Framework experiences

Today i made my first custom control for .NET Compact Framework, nothing too fancy and mostly was copy-paste from msdn website. Well, it does the job and is compatible with Visual Studio interactive designer (that was the tricky part actually). A few days ago i made some experiences with sound on managed code, i found out an awsome class for playing .wav files, the API is just amazingly simple. System.Media.SoundPlay is it's name, you can find all info about it on msdn library, it allows syncronous or assyncronous playback of .wav files, but please remember that .wav files must be encoded in PCM and that big .wav files means huge resources being allocated, so don't just put that 10min studio quality audio pcm file and expect the handheld to be all fine, but is quite useful for little sound effects. Adding to that i adapted a class i found on the internet to manage XML files in such a way that can make them behave as small databases for persistency on the device.