Click here to Skip to main content
15,900,258 members
Home / Discussions / C#
   

C#

 
GeneralRe: T4 assembly missing Pin
Richard MacCutchan8-Mar-11 7:56
mveRichard MacCutchan8-Mar-11 7:56 
GeneralRe: T4 assembly missing Pin
Pete O'Hanlon8-Mar-11 8:45
mvePete O'Hanlon8-Mar-11 8:45 
GeneralRe: T4 assembly missing Pin
Richard MacCutchan8-Mar-11 9:57
mveRichard MacCutchan8-Mar-11 9:57 
GeneralRe: T4 assembly missing Pin
Pete O'Hanlon8-Mar-11 21:14
mvePete O'Hanlon8-Mar-11 21:14 
GeneralRe: T4 assembly missing Pin
Richard MacCutchan8-Mar-11 21:29
mveRichard MacCutchan8-Mar-11 21:29 
GeneralRe: T4 assembly missing Pin
Andy Brummer8-Mar-11 16:16
sitebuilderAndy Brummer8-Mar-11 16:16 
GeneralRe: T4 assembly missing Pin
SolarEx8-Mar-11 21:36
SolarEx8-Mar-11 21:36 
QuestionWriting XML file from threads - URGENT - Pin
moums7-Mar-11 21:56
moums7-Mar-11 21:56 
Hi guys Smile | :) what zup ???? Poke tongue | ;-P
i have a big problem with thread and xml......i'm trying to write in a xml file from thread so i created a class i called them "Xmlwriter"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;


namespace xmlWriter_test
{
    class Xmlwriter
    {
        public XmlTextWriter txtWriter { get; set; }
        public string xmlPath { get; set; }
        public Object thislock = new Object();

        public Xmlwriter(string path)
        {
            xmlPath = path;
            txtWriter = new XmlTextWriter(path, null);
        }
        public void writeElement(string element, string data)
        {
            try
            {
                lock (thislock)
                {
                    //txtWriter.WriteStartDocument();
                    txtWriter.WriteStartElement(element);
                    txtWriter.WriteString(data);
                    txtWriter.WriteEndElement();
                    Console.WriteLine("good job !!");
                    //txtWriter.WriteEndDocument();
                }
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine("erreur :" + e.Message);
            }
        }
        public void startDocument()
        {
            txtWriter.WriteStartDocument();
        }
        public void endDocument()
        {
            try
            {
                txtWriter.WriteEndDocument();
            }
            catch (ArgumentException arg)
            { Console.WriteLine("erreur :" + arg.Message); }
        }
        public void closeDocument()
        {
            txtWriter.Close();
        }
    }
}


and this is my Main class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Data.OleDb;
using System.Data;
using System.Threading;

namespace xmlWriter_test
{
    class Program
    {
        static int i = 0;
        static Xmlwriter wifixmlWriter = new Xmlwriter(@"D:\wifi_test.xml");

        static void Main(string[] args)
        {
            //start document
            wifixmlWriter.startDocument();
            Thread th = new Thread(new ThreadStart(background));
            Console.WriteLine("starting thread..."); 
            th.Start();

            //end 
            th.Join();
            wifixmlWriter.endDocument();
            Console.WriteLine("press any key to quit");
            Console.ReadKey();
        }

        static public void background()
        {
            //just looop xD
            while (i<50)
            {
                Console.WriteLine("i = {0}", i++);
                //writing in the xml file
                wifixmlWriter.writeElement("hello", "i = " + i);
 
            }
        }
    }
}

that's work for the first iteration and bug after that xD i don't know why .....
and here is what i get at the end ^^
le jeton StartElement dans l'état Error générera un document XML non valid
in english = " the startElement generate an invalid XML document !!!!!!
Dead | X| thx fr help
AnswerRe: Writing XML file from threads - URGENT - Pin
OriginalGriff7-Mar-11 22:08
mveOriginalGriff7-Mar-11 22:08 
GeneralRe: Writing XML file from threads - URGENT - Pin
Richard MacCutchan7-Mar-11 22:11
mveRichard MacCutchan7-Mar-11 22:11 
GeneralRe: Writing XML file from threads - URGENT - Pin
Pete O'Hanlon7-Mar-11 23:11
mvePete O'Hanlon7-Mar-11 23:11 
GeneralRe: Writing XML file from threads - URGENT - Pin
OriginalGriff7-Mar-11 23:15
mveOriginalGriff7-Mar-11 23:15 
AnswerRe: Writing XML file from threads - Not URGENT - Pin
Richard MacCutchan7-Mar-11 22:10
mveRichard MacCutchan7-Mar-11 22:10 
GeneralRe: Writing XML file from threads - Not URGENT - Pin
moums7-Mar-11 22:20
moums7-Mar-11 22:20 
GeneralRe: Writing XML file from threads - Not URGENT - Pin
Richard MacCutchan7-Mar-11 22:28
mveRichard MacCutchan7-Mar-11 22:28 
GeneralRe: Writing XML file from threads - Not URGENT - Pin
moums7-Mar-11 22:37
moums7-Mar-11 22:37 
GeneralRe: Writing XML file from threads - Not URGENT - Pin
Richard MacCutchan8-Mar-11 0:03
mveRichard MacCutchan8-Mar-11 0:03 
GeneralRe: Writing XML file from threads - Not URGENT - Pin
moums8-Mar-11 0:10
moums8-Mar-11 0:10 
AnswerRe: Writing XML file from threads - URGENT - Pin
J a a n s7-Mar-11 22:56
professionalJ a a n s7-Mar-11 22:56 
GeneralRe: Writing XML file from threads - URGENT - Pin
moums7-Mar-11 23:43
moums7-Mar-11 23:43 
AnswerRe: Writing XML file from threads - URGENT - Pin
_Erik_8-Mar-11 0:42
_Erik_8-Mar-11 0:42 
GeneralRe: Writing XML file from threads - URGENT - Pin
moums8-Mar-11 1:03
moums8-Mar-11 1:03 
QuestionHelp w/ Security Issue Win7 Pin
Jammer7-Mar-11 12:30
Jammer7-Mar-11 12:30 
AnswerRe: Help w/ Security Issue Win7 Pin
Richard Andrew x647-Mar-11 12:50
professionalRichard Andrew x647-Mar-11 12:50 
GeneralRe: Help w/ Security Issue Win7 Pin
Jammer7-Mar-11 13:06
Jammer7-Mar-11 13:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.