solr - Wierd C# Error while creating a HTTPWebRequest in a Console Application -
i creating c# console application in have fire http url start process on hosted solr index. url firing
http://servername:8888/solr/people-dev/dataimport?command=full-import&clean=true
i using system.net.webrequest class creating httpwebrequest this:
public string execute(string url) { httpwebrequest request = (httpwebrequest)httpwebrequest.create(url); request.method = "get"; httpwebresponse response = (httpwebresponse)request.getresponse(); stream strm = response.getresponsestream(); string res = string.empty; using (streamreader reader = new streamreader(strm)) { res = reader.readtoend(); } homecoming res; }
no, whenever seek invoke function passing above url parameter, command reaches first line, tries create request, wait 1-2 seconds , terminate running instance of application.
now, don't know if has .net framework using vs2010 .net 4.0. looking help..
adding question, function called within kid task created within parent task.
is possible parent task expire before kid task execute completely. if so, how create sure not happen..
task parentimporttask = new task(() => { taskfactory tf = new taskfactory(taskcreationoptions.attachedtoparent, taskcontinuationoptions.executesynchronously); task<bool> datadumptask = tf.startnew<bool>(() => { string sqlquery = @"[dbo].[importkonnectpeopledataforindexing]"; using (sqlconnection connection = dbconnection.getsqlconnection("konnectdatadumpdb")) { int importstatus = -1; seek { sqlcommand command = new sqlcommand(sqlquery, connection); command.commandtype = system.data.commandtype.storedprocedure; command.commandtimeout = 900; importstatus = command.executenonquery(); } grab (exception e) { logger.log("exception occured in info import task solr/people::index"); throw e; } { connection.close(); } if (importstatus > 0) { homecoming true; } homecoming false; } }, taskcreationoptions.attachedtoparent).continuewith((i) => { if (!i.result) { throw new exception("data dump task not successfull solr/people::index"); } homecoming solrconnector.execute(url); }, taskcontinuationoptions.onlyonrantocompletion); }, taskcreationoptions.longrunning); parentimporttask.runsynchronously(); parentimporttask.wait();
there seems nil wrong application. console applications close done. add together console.readkey() end of application , wait until have pressed button close.
c# solr .net-4.0 system.net.httpwebrequest
No comments:
Post a Comment